How to reseed a primary key??

  • Thread starter Thread starter Akhil
  • Start date Start date
A

Akhil

Hi,

How would you do this in C#.

How would you regenerate (reseed??) a primary key in a table?

and

What is the difference between primary key and unique key?

Regards,
Akhil
 
Hi,

How would you do this in C#.

How would you regenerate (reseed??) a primary key in a table?

Not sure
and

What is the difference between primary key and unique key?

A primary key is an ID tag on every row, kind of like a social security number with no possible duplicates.
The database needs it to perform certain actions.

A unique key is just a value the is just that, unique. Specifying unique you ensure that no two rows can have the same unique key. A primary key is also unique, but you can only have one primary key, but several unique. For instance, having EmployeeID as primary key, then you could have social security number as unique.
 
DBCC CHECKIDENT
Checks the current identity value for the specified table and, if needed,
corrects the identity value.

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.
 
Back
Top