Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the New record Id

Status
Not open for further replies.

LittleSmudge

Programmer
Mar 18, 2002
2,848
GB
Hi folks.

I'm a visitor from the MS Access and MySQL boards.

I have a requirement to insert/update one table in someone else's SQLServer database.

When I write a new record to an Access database using ADO I can get the auto generated Primary Key easily.

When I write a new record to MySQL via ODBC I get the new Primary Key back using

rstGetId.Open "SELECT Last_Insert_Id() As SNId", MyConn


How do I get the Auto Generated Primary Key back from SQL Server over ODBC when I write a record to this other person's database ?



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Look up @@identity and scope_identity from BOL.

eg...
SELECT @@IDENTITY AS 'Identity'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top