Get the next id_mssql that will be inserted in the self-added column

Source: Internet
Author: User
Copy Code code as follows:

DECLARE @Table_name varchar (60)
Set @Table_name = ' Pay_inputpay ';
Select so.name table_name,--table name
Sc.name Iden_column_name,--Self-added field name
Ident_current (So.name) Curr_value,--self-added field current value
IDENT_INCR (So.name) Incr_value,--Self-increasing field growth value
Ident_seed (So.name) Seed_value--Self-increasing field seed value
From sysobjects so
Inner Join syscolumns SC
On so.id = Sc.id
and ColumnProperty (sc.id, Sc.name, ' isidentity ') = 1
Where Upper (So.name) = Upper (@Table_name)
--@Table_name is the passed-in parameter table name Curr_value This is the ID to be inserted

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.