Php + mssql getting the last inserted id value (online, etc ~) I remember that mysql has a mysql_insert_id () function to obtain the last inserted id, for example, $ newID = mysql_insert_id (); what about the mssql database? Is there such a function? How can I output the last inserted id php + mssql to obtain the last inserted id value (online, etc ~)
I remember that mysql has a mysql_insert_id () function to obtain the last inserted id, for example, $ newID = mysql_insert_id (); what about the mssql database? Is there such a function? How can I output the last inserted id?
------ Solution --------------------
At least not found in the manual,
Query once.
Mssql has its own system variables
------ Solution --------------------
Discussion
Query select @ IDENTITY
Mssql has its own system variables
------ Solution --------------------
Discussion
No, do you have to write it like this? Is there any other way? I did not find such a function. The combination of mssql and php made me very uncomfortable. what I am doing now is a master-slave table structure, you need to store the id of the master table to insert data from the table.
------ Solution --------------------
Discussion
It is not difficult. if the primary key is a student ID, rather than an incremental identifier, what should I do?
------ Solution --------------------
Select @ IDENTITY can be used if INSERT exists.
I have never seen any problems upstairs.
Is there a problem with concurrency?
Where should I write a stored procedure?
------ Solution --------------------
In addition to the stored procedure, the simplest and most direct method is to construct a query to ensure the uniqueness of the query conditions.
------ Solution --------------------
Select once after insertion... find the id ..
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service