Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 @@identity and triggers

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-08 : 19:02:55
Mikhail writes "Hello,
you have a tip on how to retrieve latest inserted identity value. It usess @@identity. But what if there is a trigger on the table being inserted and that trigger causes an insert into another table?
From my experience, @@identity returns from the last table inserted.

The only workaround I found was the following:
BeginTrans
INSERT INTO tableA
SELECT myID = MAX(id) FROM tableA
CommitTrans

Any suggestions?

thank you,
Mikhail"
   

- Advertisement -