0

Can you tell me how to insert executed variable @name in my table? I had some coding and this is what i managed to do but I do not know whats next:

DECLARE @Name nvarchar(200);
DECLARE @dbcatalog nvarchar(128);
declare @sql nvarchar(4000)



    select @name = N' select ID from ' + @DbCatalog + '.dbo.Table2 ';

   SET @sql =  'insert into Table2(Name) values (@name)'
   exec Sp_executeSQL @sql

1 Answers1

0

Are you trying to copy ID values from one table into another? If so, then:

INSERT INTO Table2 (Name)
EXEC(@Name)
Junc Mayl
  • 91
  • 5