J_hajian_nzd
J_hajian_nzd

Reputation: 185

alter a table column and set identity from max existing in that column in sql server 2008

I have a Column with MaxCode name, in Mytable that filled before,now i want alter this column and set it type to identity that start with max number existing in column MaxCode

Upvotes: 1

Views: 91

Answers (1)

techspider
techspider

Reputation: 3410

Use below code to reset seed value for Identity column

DECLARE @newSeed NUMERIC(10)
SELECT @newSeed = MAX(MaxCode) FROM Mytable
DBCC CHECKIDENT (Mytable, RESEED, @newSeed)

Upvotes: 1

Related Questions