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 2005 Forums
 Transact-SQL (2005)
 Retreive newly added Identity column value

Author  Topic 

timmemac
Starting Member

6 Posts

Posted - 2010-05-12 : 20:12:45
Hi,

I have a table purchases,the column PurchaseNo is auto incremented each time a new record is inserted.The insertion is done using a Stored Proc.How to retrieve newly added PurchaseNo.Pls list all the possible ways


Regards
Tim

ms65g
Constraint Violating Yak Guru

497 Posts

Posted - 2010-05-12 : 20:24:04
[code]SELECT @@identity AS newID[/code]
Go to Top of Page

dineshrajan_it
Posting Yak Master

217 Posts

Posted - 2010-05-13 : 08:47:16
scope_identity() is more preferred than @@identity as @@identity may fail when the table has trigger in it

Iam a slow walker but i never walk back
Go to Top of Page
   

- Advertisement -