In SSIS, How do I use the execute SQL task to insert a single row with no parameters and get the primary key back so I can set it to user variable? My insert query is simply
Here is another alternative I think is very clean. It uses OUTPUT syntax and the Result Set instead of Parameter Mapping, which requires less configuration.
insert dbo.ImportData (EndDate)
output inserted.Id
values (NULL);
Id
in this statement with the name of your identity column.0
(meaning the first column) and select your variable name e.g.
User::tablePk
(Variable type: Int32)