J.J.Baxter - My place on the web - interests, hobbies, thoughts & ruminations
Home / Blog
Books
Links
Images
Aug Sep-2010 Oct
SMTWTFS
2930311234
567891011
12131415161718
19202122232425
262728293012
3 4 5 6 7 8 9
Reset Calendar
Snorg Girls
Programming Tips
Sherlock Holmes
Mythbusters
Gallipoli
Nova Science Now
Ajax Loading Images
The Girls of Dr. Who
Keratosis Pilaris (KP)
Amazing Water
Buy me a drink? I'll have a Cappuccino, thanks.
Random Images
Random Link
Tahlei's PhotoBlog
Random Book
Odyssey
by Jack McDevitt






All Rights Reserved 2008
JJBaxter.com

J.J.Baxters Development Tips & Snippets
backBack
 Get the identity of the record just created (SQL : 05-Jun-2007)
To retrieve the identitty of the last record created I used to use

sSQL = "SELECT @@IDENTITY AS NewID"
iNewID = oCon.execute(sSQL)("NewID")

But it has too many problem so I switched to

sSQL = "SELECT IDENT_CURRENT('fit_bookings') AS NewID"
iNewID = oCon.execute(sSQL)("NewID")

And it seems to work fine. I have also seen

SCOPE_IDENTITY()

But have never used it. There is another introduced in SQL 2005 (Output?) but havent read anything of it as yet.
Ref Link: http://www.dbazine.com/sql/sql-articles/cook18/