Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

@@identity Expand / Collapse
Author
Message
Posted Friday, October 18, 2002 5:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, October 18, 2002 12:00 AM
Points: 3, Visits: 1
Hello everyone,
I was wondering does anyone know who to use @@identity function? Thanks




Post #7532
Posted Friday, October 18, 2002 5:42 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: Moderators
Last Login: Yesterday @ 9:01 AM
Points: 6,705, Visits: 1,680
declare @NewKey int
insert into table1(col) values (blah)
select @NewKey=@@Identity

If you're using SQL2K you should use the scope_identity() function instead.

Andy
http://www.sqlservercentral.com/columnists/awarren/




Andy
SQLAndy - My Blog!
Connect with me on LinkedIn
Follow me on Twitter
Post #44131
Posted Friday, October 18, 2002 10:07 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, March 13, 2014 10:40 AM
Points: 573, Visits: 107
If you are using SQL 7 and triggers be careful, as you the identity gets over written

Simon Sabin
Co-author of SQL Server 2000 XML Distilled
http://www.amazon.co.uk/exec/obidos/ASIN/1904347088



Simon Sabin
SQL Server MVP

http://sqlblogcasts.com/blogs/simons
Post #44132
Posted Friday, October 18, 2002 11:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, October 18, 2002 12:00 AM
Points: 3, Visits: 1
No, I am using sybase, which is very similar to 6.5 sql server, and I am using @@identity in a stored procedure...




Post #44133
Posted Friday, October 18, 2002 11:06 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, October 18, 2002 12:00 AM
Points: 3, Visits: 1
Thanks Andy, this seems to work!!!




Post #44134
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse