How to use tMSSqlLastInsertId ?

One Star

How to use tMSSqlLastInsertId ?

Hi I am reading a CSV file and inserting into a table in MS SQL server using TOS.
In the tMSSqlOutput table, I removed the schema for ID column because in MSSql server it is auto increment by default.
The Job is doing well. I am able to insert many rows into the table. In MSSql server each row will be inserted with ID column value incrementing by one.
I want to get the last inserted ID value in the MSSql Server in Talend.
Say in MSSQL after adding the new rows from CSV file , the last row ID is 50, I want to get the value 50.
I tried tMSSqlLastInsertId component. and I am trying to print it.
This is my Job
tFileInputDelimited -----> tMap ---> tMSSqlOutput -----> tMSSqlLastInsertId -----> tMap ---> tLogRow

In tMSSqlOutput, there are many columns in schema. But the primary key column is not added since there is problem in adding Identity column.
In tMSSqlLastInsertId there is only one coumn I found. I tried mapping it directly to logrow,
But it was showing Null pointer exception.
Can someone help me in that. I want to know how to connect and the mapping between tMSSqlOutpt to tLogRow
Thanks
One Star

Re: How to use tMSSqlLastInsertId ?

hy,
You can try it like shown on the images.
1) Add the tMssqlLastInstertID after the output component
2) Add the new lastinsert column
3) uncheck "Use batch size" in tMssqlOutput
regards,
robert
One Star

Re: How to use tMSSqlLastInsertId ?

Thank you