Creating SQL table using dynamic variable name

前端 未结 5 956
滥情空心
滥情空心 2021-02-05 17:23

I want to create backup SQL tables using variable names.

something along the lines of

DECLARE @SQLTable Varchar(20) 
SET @SQLTable = \'SomeTableName\' +         


        
5条回答
  •  故里飘歌
    2021-02-05 18:00

    Unfortunately, you can't use bind variables for table names, column names, etc. IN this case you must generate dynamic SQL and use exec.

提交回复
热议问题