mwok
mwok

Reputation: 257

Get last row inserted

I have a trigger that inserts a record into a diff table but I need to get that record that was inserted inside the trigger, how do I do it? There is no identity field, only account_nbr that is generated by a separate trigger on the insert table.

I don't know if there is sql statements to retrieve a row that was just inserted.

DB is Sql Server 2008.

Upvotes: 4

Views: 761

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062550

The OUTPUT clause will give you back the records you have just inserted: http://msdn.microsoft.com/en-us/library/ms177564.aspx

If you mean the rows inserted before the trigger invoked, they are in the inserted pseudo-table.

Upvotes: 5

Related Questions