RE: [PHP-WIN] Retrieving ID after INSERT with MSSQL
| From: | Flint Doungchak | Date: | Fri, 15 Dec 2000 16:53:32 +0000 |
| Subject: | RE: [PHP-WIN] Retrieving ID after INSERT with MSSQL | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-4505@lists.php.net to get a copy of this message | ||
Fabio,
You can use the MSSQL function
@@IDENTITY to retrieve the last insert id of a column with an indentity
seed. i.e. is autoincremented by SQL Server.
So, it would look something like this...
$query = "INSERT INTO blah values (a,b,c)";
$result = mssql_query($query,$connect);
$query = "SELECT @@IDENTITY";
$whatyouwant = mssql_query($query,$connect);
-Flint
-----Original Message-----
From: Fabio R. [mailto:fabio@zolnetwork.com]
Sent: Friday, December 15, 2000 8:40 AM
To: 'PHP-Windows List (E-mail)'
Subject: [PHP-WIN] Retrieving ID after INSERT with MSSQL
Hello,
is there a function like "mysql_insert_id" for MS SQL? I need to retrieve
the ID of the last INSERT operation, but I can't find a function like I
found in mysql.
Is there an alternative method to retrieve it?
Thanx all.
Fabio
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
For additional commands, e-mail: php-windows-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net