How can I set identity_insert on a tablename passed as a variable
I’m using the below sql queries in my stored procedure to copy the records from existing table to duplicate table and ended up at the below error Script: -- Step 4: Temporarily allow identity insert on the new table SET @sql="SET IDENTITY_INSERT " + @new_table + ' ON' EXEC sp_executesql @sql -- Step 5: Copy