Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Labels (3)
2 Replies
Anonymous
Not applicable
Author

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
0683p000009MB8N.png 0683p000009MAvG.png 0683p000009MB8S.png
Anonymous
Not applicable
Author

Thank you