I am trying to create dynamic tables with dynamic columns from one database to another using stored procedure. Since i have sequel of queries and conditions i am using it. But facing issue:
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '('.
Below is the line where i meet error:
Execute( 'USE ' + @DB1+ ';CREATE TABLE DB2.dbo.'+ @TableName + ' AS (SELECT * [email protected].'+@TableName +')' );
thanks in advance!!