Discover sql server get last inserted id, include the articles, news, trends, analysis and practical advice about sql server get last inserted id on alibabacloud.com
SQL Server 2000 has three similar functions: scope_identity, ident_current, and @ identity. Both return values inserted into the identity column.Nbsp; ident_current returns the final id value generated for any session and a specific table in any
In actual database applications, we often need to get the inserted flag value to write data into the relevant table. But what we usually get is the value we need?Sometimes we use select @ identity to obtain the value we just inserted, such as the
Ident_current returns the identity value that was last generated for any session and for a particular table in any scope. Ident_current is not subject to scope and session restrictions, but is limited to the specified table.
@ @IDENTITY Returns
Select @ identity usage 11:25:39| Category: JSP Dev|Report|Font SizeSubscription Use select @ identity to obtain the ID automatically generated when the last record is inserted. If you use a stored procedure, the Code is as follows: Set @ [email
[Original address:] The differences between scope_identity, ident_current, and @ identity (comparison)
@ Identity (TRANSACT-SQL) returns the system function of the last inserted Identifier value.
Note: After an insert, select into, or large-capacity
A recent problem in the development project was to get the ID in the database immediately after inserting a record, and that ID was self increasing. There are several ways in which SQL Server 2005 can be implemented. The easiest way to get this ID
[PHP] MySQL obtains the primary key (auto-increment ID) of the inserted data. to prevent primary key conflicts, the auto-increment (auto_increment type) field is often used during database design. Therefore, the primary key of the modified record is
[PHP] MySQL obtains the primary key (auto-increment ID) and mysql primary key of the inserted data.
To prevent primary key conflicts, auto-increment (auto_increment type) fields are often used in DB Design. Therefore, the primary key of the
Insert
How to get an ID automatically generated after the last time you insert a record
Author: Amoy Net
Source: Amoy Net
NOTE: Reprint please indicate the source
If you use stored procedures, it will be very simple, the code is as follows: SET
Just now I saw a friend in the blog Park
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
//
Locate the id value just inserted
Datatable dt
=
Helper. getdatatable (
"
Select top 1
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.