I have used OLE DB Destination
to insert data to the SQL server table. Is it possible to get the Inserted ID
from the table without using query.
I can achieve this using
INSERT INTO testBook(name) VALUES ('Test Book')
SELECT SCOPE_IDENTITY()
by selecting data access mode to SQL COMMAND
.
But Is there any way to achieve this without using SQL query and using only the SSIS components?
Please advice.
If i have this issue, i will add an Execute SQL Task
after the DataFlow Task
, and i will use the following command to get the Identity (or i can use one of the Identity function to retrieve it) :
SELECT MAX(ID) FROM testBook
And i will map the result to a variable
You can also use OLEDB Command
instead of OLEDB Destination
. you can follow This Article for a detailed solution.
While searching i found these two similar questions asked on this website, you can refer to one of them.