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.
| Author |
Topic |
|
bjurlina
Starting Member
1 Post |
Posted - 2004-06-05 : 06:14:47
|
| how can I set my primary key to star again from 1?? for example, if I had a table with some rows in it and I deleted all that rows, next time when I insert a new row in that table, primary key starts from last primary key of previous rows, but I want it to start again from 1.is that possible?? thanks! |
|
|
gpl
Posting Yak Master
195 Posts |
Posted - 2004-06-05 : 08:27:40
|
| Use Truncate table <tablename> This clears out the rows and resets the identity seed |
 |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2004-06-05 : 08:55:05
|
| You cannot run a TRUNCATE on a table participating in a foriegn key constraint. In that case you can use DBCC CHECKIDENT, see books online for more details.OS |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-06-05 : 16:20:03
|
| DBCC CHECKIDENT('table','RESEED',0)MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|