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 > ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |