Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 AUTO INCREMENT

Author  Topic 

csosa
Starting Member

5 Posts

Posted - 2009-03-04 : 10:01:55
I have a question. I have deleted all the data I had on my tables. I would like the auto-increment OR the IDENTITY fields to start from 1 again. How can I do this??

Thanks in advance
Carlos

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-04 : 10:03:38
use
DBCC CHECKIDENT()
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-04 : 10:04:12
see

http://doc.ddart.net/mssql/sql70/dbcc_5.htm
Go to Top of Page

shaggy
Posting Yak Master

248 Posts

Posted - 2009-03-04 : 10:08:18
DBCC CHECKIDENT ('tablename', RESEED, 0);
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-04 : 10:10:05
Also, If you deleted all data using truncate,, then identity will be reset on its own. If you ran a delete,, it'd continue from the last id inserted. You'd then have to reseed it.
Go to Top of Page

csosa
Starting Member

5 Posts

Posted - 2009-03-04 : 11:09:05
Thank for the help!
I have a couple of questions.
Whats the best datatype to use for memo (LONG TEXT) fields?
Whats the diference between NCHAR and VARCHAR?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-04 : 11:12:37
if using sql 2005 or later, use varchar(max) or nvarchar(max)
NCHAR means unicode, it takes twice the storage of char
Go to Top of Page
   

- Advertisement -