Let the ID field start counting again

Source: Internet
Author: User
DBCC CHECKIDENT

Check the current Identifier value of the specified table. If necessary, correct the Identifier value.

Syntax

DBCC CHECKIDENT
('Table_name'
[,{NORESEED
| {RESEED [, New_reseed_value]}
}
]
)

Parameters

'Table_name'

Is the name of the table whose current identity value is to be checked. The table name must comply with the identifier rules. For more information, see use identifiers. The specified table must contain an ID column.

NORESEED

Specifies that the current ID value should not be corrected.

RESEED

Specifies that the current ID value should be corrected.

New_reseed_value

Is the value to be used when the value is re-assigned in the ID column.

Example A. Reset the current ID value if necessary

The following example is reset if necessary.JobsThe current Identifier value of the table.

USE pubsGODBCC CHECKIDENT (jobs)GO
B. report the current ID value

Example reportJobsThe current ID value in the table. If the id value is incorrect, it is not corrected.

USE pubsGODBCC CHECKIDENT (jobs, NORESEED)GO
C. Force the current ID value to 30

Force the following exampleJobsThe current ID value in the table is 30.

USE pubsGODBCC CHECKIDENT (jobs, RESEED, 30)GO

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.