Skip to content
Advertisement

Does having two or more calls to scope_identity() in a single procedure work?

Does having 2 or more calls to scope_identity() in a single procedure work?

For example:

For sure @id_1 gets the last inserted id of table_1. The question is, does @id_2 get the last inserted id of table_2?

Advertisement

Answer

Yes, sure – if both table_1 and table_2 for an identity column – why not??

But please use this syntax:

No need for both a set and a select

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement