Hello, Here is my query sample. SELECT * INTO [Master_Table] FROM My_Table I like to use a CREATE VIEW that includes this query. Something like this. EXEC('CREATE VIEW [View_Master_Table] AS SELECT * INTO [Master_Table] FROM My_Table ') When I run the View an error occurred. SELECT * FROM [View_Master_Table] **Incorrect syntax near the keyword 'INTO'.** Any help would be much appreciated
By default, the CREATE VIEW statement doesn't allow the INTO keyword. Furthermore, even if you could, you would only be able to execute the view once as the table will only be created once. Reference:
https://msdn.microsoft.com/en-us/library/ms187956.aspx This type of logic probably should be in a stored procedure. I don't know what you are doing, but using a temporary table might be better suited than a physical table. Just throwing that out there. Hope that helps!