note 84776 deleted from function.mssql-query by danbrown
| From: | danbrown@php.net | Date: | Tue, 29 Jul 2008 20:37:09 +0000 |
| Subject: | note 84776 deleted from function.mssql-query by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142907@lists.php.net to get a copy of this message | ||
Note Submitter: Jos
----
Even if the ID is not an IDENTITY column, you can still use OUTPUT to return the ID (supposing the
ID is still auto-generated by a trigger or another function):
INSERT INTO [myTable] ([name], [address]) OUTPUT INSERTED.[userId] VALUES ('Jos',
'Somewhere')
It will return userId from the newly inserted record.
This works well with SQL Server 2005 - I don't know about older versions.