[thelist] Free Tip about SQL
Joshua Olson
joshua at waetech.com
Fri Jul 18 11:30:35 CDT 2003
----- Original Message -----
From: "Rob Smith" <rob.smith at THERMON.com>
Sent: Friday, July 18, 2003 11:53 AM
> A colleague of mine came up to me and asked:
> "Is there a way, in a SQL statement, to return the auto generated ID of a
> record when it's created by an insert values query? ..."
>
> I answered:
> "Add another column in your table for a timestamp varchar(24) variable.
> Store that number as a variable. Then at your leisure call for a row that
> contains your newly added timestamp variable and you'll have the new ID.
Rob,
In MS SQL Server the variable @@identity contains the id of the last auto
generated ID. Other databases usually have something equivalent.
Also, a GUID may provide you an alternative to using a timestamp.
Good luck,
<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com
706.210.0168
More information about the thelist
mailing list