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 of multiple records of same table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-10 : 00:46:27
girish writes "hi
this is the question related to the same topic.
I am using Insert statement and inserting multiple records through - insert - select combination. I want to get the @@identity of all the records inserted. Is it possible ( I am updating records to same table)

thanks in advance"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-06-10 : 07:17:30
Within an INSERT trigger, the inserted pseudo-table contains all of the newly inserted rows. You can join this table to the normal table using the primary key:

CREATE TRIGGER ExtraUpdate ON myTable FOR INSERT AS
UPDATE M
SET M.ThisColumn='Hello!'
FROM myTable M INNER JOIN inserted I
ON M.IDCol=I.IDCol


Take a look in Books Online for more information on triggers.

Go to Top of Page
   

- Advertisement -