What the question title says. With a query such as SELECT @@IDENTITY AS ins_id, do I need to supply the table name or any other info to specify which table/database i’m talking about?
What the question title says. With a query such as SELECT @@IDENTITY AS ins_id
Share
@@IDENTITYreturns the most recent identity generated in the current session. In most cases you’ll probably want to useSCOPE_IDENTITYinstead, which returns the most recent identity generated in the current scope.For example, if you insert a row into table1, but that insert fires a trigger which inserts a row into table2, then
@@IDENTITYwill return the identity from table2 whereasSCOPE_IDENTITYwill return the identity from table1.