[AccessD] [OT] Determine ID of inserted record on SQL server

Mackin, Christopher CMackin at quiznos.com
Wed Jan 5 10:39:02 CST 2005


After the INSERT SQL is executed, you can return the value of the Identity Column by using the SQL:

SELECT @@Identity
or 
SELECT @MyVariableToHoldID = @@Identity
to put the value into a variable.

-Chris Mackin



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of MarkH
Sent: Wednesday, January 05, 2005 9:11 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] [OT] Determine ID of inserted record on SQL server


Hello...

Using SQL Server 2000 and Acces XP.

I have a stored procedure that inserts records into a table that uses an
identity column (i.e. automatically generated ID). I want to extend the
procedure to create related records in other tables using the same ID.
Anyone know how I can retrieve the ID of the new record from within the
SP.

I'm pretty sure this can be done as I remember doing it years ago whilst
working with active server pages and a sql server backend. Can't
remember how though and have no copy of the code...

Any ideas much appreciated...

Mark

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.827 / Virus Database: 564 - Release Date: 03/01/2005
 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list