Hi,
how can reset the identity column in Sql Server ?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
NIlesh Patel32 reputationPosted Apr 28, 2012, 3:48 AM EDT
It can not Possible to Reset Identity Column In Sql Server. But By using 'Truncate Table Tablename ' This Query It can Reset But Data Also Deleted.
brunda kRank #3,804 · 389 reputationPosted Apr 28, 2012, 5:11 AM EDT
(
table_name
[, { NORESEED | { RESEED [, new_reseed_value ] } } ]
)
[ WITH NO_INFOMSGS ]
http://msdn.microsoft.com/en-us/library/ms176057.aspx
MuthuMari MRank #5,738 · 288 reputationPosted Apr 28, 2012, 8:55 AM EDT
Using the DELETE/Truncate statement is not enough. The statement only deletes the data but not reset the identity column.
So how can we do it? First, wen need to delete the data from the table(truncate the table) and after execute the DBCC command with CHECKIDENT switch in order to reset the data
The following line resets the Identity value for the Customer table to 0 so that the next record added starts at 1.
DBCC CHECKIDENT('Customer', RESEED, 0)thanks
If this post is useful then mark it as "Accepted Answer"
Satyapriya NayakRank #47 · 31.5K reputationPosted Apr 28, 2012, 10:43 AM EDT
Please refer the below link
http://www.codeproject.com/Tips/264381/How-to-RESET-identity-column-in-SQL-Server
Thanks
SenthilkumarRank #387 · 6.5K reputationPosted Apr 28, 2012, 7:30 PM EDT
Hope this will help you.