Wednesday 3 October 2007

Trunc with Replication and reseeding indexes

Thanks to Allister for this one.

With replication in SQL Server 2005 you cannot trunc a database table.

Therefore you have to delete the contents of the table and reseed the index.

DELETE MyTable
DBCC CHECKIDENT ( 'MyTable', RESEED, 0 )

The reseed command is useful for those tables where you need to reseed in 2 way replication (because you have been a naughty boy and have not used guids).

No comments: