Unix Technical Forum

Re: Find out key from Insert Statement

This is a discussion on Re: Find out key from Insert Statement within the SQL Server forums, part of the Microsoft SQL Server category; --> Mithu (mithu.feb03.nntp@powertechcanada.com) writes: > If you do an insert statement into a SQL Server 2000 database that has > ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:00 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Find out key from Insert Statement

Mithu (mithu.feb03.nntp@powertechcanada.com) writes:
> If you do an insert statement into a SQL Server 2000 database that has
> an autonumber (identity) field - is there any way to find out what the
> auto-generated key that was assigned to your insert was? I'm adding
> invoices to a db over PHP and I don't know of any easy way to insert a
> new record and then find out what the auto-generated number was - any
> help would be appreciated. Sample insert included below:


SELECT scope_identity() after the INSERT statement.


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:09 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com