Retrieving id of inserted record: What to use @@IDENTITY or SCOPE_IDENTITY() or OUTPUT
Hi guys, This seems very basic information but need to know properly. Issue: I need to find out or have the id of the records which I inserted in table. Analysis: This requirement seems very simple but there could be various cases where you would not get the correct id just by using @@IDENTITY function. Think of the case where you are inserting a record in table A and there is a trigger which fires as soon as there is a insert in table A which insert a record in table B. so in such case @@IDENTITY wont give you the … Continue reading →