|   | ![]() |
|
How can I clear a table and
reset the identity back to 0? If there are no foreign keys on the table then a simple TRUNCATE TABLE <tbl> will do the trick. If there are foreign keys then first delete all rows - DELETE <tbl> Then reset the identity :- Under 7.0 - DBCC CHECKIDENT(<tbl>,RESEED,0) Under 6.5 - DBCC CHECKIDENT(<tbl>) |
All content on this site, except where noted, represents an original work of Michael R. Hotek and is protected by applicable copyright laws. The SQL Server FAQ is the sole work of Neil Pike. No page, portion of a page, or download may be used for commercial purposes in whole or in part without the express, written permission of the applicable author.