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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Identity record

Author  Topic 

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-28 : 23:28:53
I created a table that has an identity field set up.
I inserted a record and it was not the record i wanted associated with this particular identity seed. I deleted the record and inserted the record I wanted and now the identity value is 2 instead of 1. Is there anyway i can explicity state the record i want in there to an Identity value of 1?

Keithc MCSE MCSA

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-06-28 : 23:36:54
SET IDENTITY_INSERT wives ON

INSERT wives(order, description)
SELECT 1, 'She hates me'

SET IDENTITY_INSERT wives OFF

You will also probably want to reseed it so the next number is 1.

DBCC CHECKIDENT('wives',RESEED,1)

This reseeds the table by the way.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-28 : 23:57:09
Thanks for the help, worked perfectly



Keithc MCSE MCSA
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2004-06-29 : 11:42:47
Also truncating the table resets the identity columns

------------------------
I think, therefore I am
Go to Top of Page
   

- Advertisement -