@ Identity Stored Procedure

Source: Internet
Author: User

These are from online books:
@ Identity Stored Procedure
Returns the last inserted id value.

Syntax

@ Identity

Return type

Numeric

Note

After an insert, select into, or large-capacity copy statement is completed, @ identity contains the final id value generated by this statement. If this statement does not affect any table with an ID column, @ identity returns NULL. If multiple rows are inserted, multiple ID values are generated. @ identity returns the final id value. If one or more triggers are triggered to execute the insert operation that generates the id value, @ identity is called immediately after the statement is executed, and the last id value generated by the trigger is returned. If the insert or select into statement fails, the large-capacity copy fails, or the transaction is rolled back, @ identity The value is not restored to the previous setting.

Example

The following example inserts a row into a table with an ID column and uses @ identity to display the id value used in the new row.

Insert into jobs (job_desc, min_lvl, max_lvl) values ('accountant ', 12,125) Select @ identity as 'identifi'

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.