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 |
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2009-08-19 : 12:07:46
|
| I am using identity type for the primary key in a table. When inserting some records - I realized I missed some data. So, I will delete data for a period and re-insert.When this happens - SQL Server remembers the last number for the id column and uses the next number for Insertion. So before delete - if the last id was 6047000 and now I delete 47000 records, the last id is 6000000. For the re-insert, SQL Server will use 6047001, not 6000001.Even though it's not a big problem - I was curious if there is any way to force it to use 6000001 instead.Thanks. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-08-19 : 12:11:42
|
| DBCC CHECKIDENT |
 |
|
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2009-08-19 : 12:47:50
|
| I checked the syntax and found it is like:DBCC CHECKIDENT ( table_name, RESEED )So, should I use it once before starting the Insertion loop?Thanks. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-08-19 : 12:59:51
|
| Yes. |
 |
|
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2009-08-19 : 13:36:47
|
| Thanks very much. |
 |
|
|
|
|
|