Pages

Search

Monday, July 13, 2009

How To Reseed Table Identity on SQL

To reseed table identity in SQL we will going to use the function DBCC CHECKIDENT

Syntax

DBCC CHECKIDENT
( 'table_name'
[ , { NORESEED
| { RESEED [ , new_reseed_value ] }
}
]
)

Arguments

'table_name'

Is the name of the table for which to check the current identity value. Table names must conform to the rules for identifiers. For more information, see Using Identifiers. The table specified must contain an identity column.

NORESEED

Specifies that the current identity value should not be corrected.

RESEED

Specifies that the current identity value should be corrected.

new_reseed_value

Is the value to use in reseeding the identity column.


Example:

DBCC CHECKIDENT (My_Table, reseed, 0)

This example will reseed table My_Table, and the identity seed will start 1 again

No comments:

Post a Comment