MS SQL Server - how to reseed an Identity field counter lazarus / 16-Databases ---------------------------------------------------------------------- Graeme · 2014-09-02 09:20 I'm working with an existing MS SQL Server database. The database uses Identity type fields for the primary keys. I've written an app that imports data from a CSV file, but I need to reseed the primary key field to 0 when importing the data. Has anybody reseeded such a field type via SqlDB? Is it possible? Anybody know if I can execute something like the following via SqlDB:   Code: [Select]DBCC CheckIdent(, RESEED, 0) Alternatively, what about the ability to run this:   Code: [Select]set identity_insert on|offso I can populate the identity field with my own auto-increment number? I would prefer the RESEED option, but either one would do really. ---------------------------------------------------------------------- taazz · 2014-09-02 09:41 IT would help if you told us which version of mssql you are using in mean time try executing the command Code: [Select]DBCC CHECKIDENT (mytable, RESEED, 0) where 0 (last parameter) is the last used number the next insert will have the value 0+1. Also check with online help to see if that requires SA access. ---------------------------------------------------------------------- Graeme · 2014-09-02 10:46 Thanks Taazz. I'm using SQL Server 2004 up to SQL Server 2012. For some reason I didn't think the DBCC commands was allowed outside of Microsoft SQL Server Management Studio, but it works perfectly via SqlDB. My problem is now solved. :-) ---------------------------------------------------------------------- KanVee04 · 2014-09-02 10:48 I am new pascal. Could please tell how to create a WYSIWYG Editor using pascal script. ---------------------------------------------------------------------- Graeme · 2014-09-08 20:08 Don't reply to an existing thread and change the subject line - nobody will see your question. Create a new topic in a relevant forum instead.