Msg 2812 : "Create Table Using Dynamic Script"
I wanted to Create a table using dynamic script.
If I creates a table using
CREATE Table TodayTemp(id varchar(20))
DROP TABLE TodayTemp
Then there is no problem. Its working fine. but problem using this is I
can't create columns dynamically. hence I tried using store Create script
in a variable and then finally execute them using EXEC command. Like
Declare @CreateTableCmd varchar(max)
SET @CreateTableCmd = 'CREATE Table TodayTemp(id varchar(20))'
Exec @CreateTableCmd
But it Gives me an error
Msg 2812, Level 16, State 62, Line 6 Could not find stored procedure
'CREATE Table TodayTemp(id varchar(20))'.
Here is the SQLFiddle Demo
No comments:
Post a Comment