Not quite sure what the problem is. Your code works for me:declare @sql nvarchar(max) = 'declare @t table (col1 varchar(100), col2 varchar(100));declare @var1 varchar(100) = ''Henry'', @var2 varchar(100);insert into @t (col1, col2)select @var1, @var2;select * from @t'exec (@sql)
Results:(1 row(s) affected)col1 col2---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------Henry NULL(1 row(s) affected)