When trying to insert a value into a table coming from a dynamic SQL this is working perfectly.
INSERT TableName(ColumnName1) EXEC('SELECT '+@ColumnName+' from kat.[dbo].[History] ')
However, when I want to insert more than 1 value with this Dynamic SQL this is not working anymore.
INSERT TableName(ColumnName1, ColumnName2) EXEC('SELECT '+@ColumnName+' from kat.[dbo].[History] '), datum from kat.[dbo].[History] .
Is there a reason for this?
May thanks in advance,
Kat