|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to force the primary key for a table to begin at a set Primary Id and not standard count (1,2,3,4,5..10,11,12) etc.
Pretty much how to force it being on number I would like to begin. |
|
#2
|
||||
|
||||
|
have a look in BOL for "DBCC CHECKIDENT" ...
__________________
Come JOIN the party!!! Quote of the Month: Retirement: Because you've given so much of yourself to the company that you don't have anything left we can use. Questions to Ponder: What do you do when you see an endangered animal eating an endangered plant? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright© 2008 sbenj69 |
|
#3
|
|||
|
|||
|
I've done this 2 different ways.
1. Add n-1 blank records so that your real data starts at record n. Then delete the blank recods. 2. There is a command to turn off the primary key autonumber and allow you to insert the primary key. Insert your first record with the primary key you want, then turn the primary key back on. (Sorry I forget the command I just remember that I've done it.) |
|
#4
|
|||
|
|||
|
From The Point Where You Create The Table
This is not a PRIMARY KEY problem, but an IDENTITY issue.
IDENTITY sets the counter for a column. When creating a column for a table that you want a counter on, you need to use an IDENTITY property for the column as follows: CREATE TABLE dbo.TestTable ( TestID int IDENTITY(1,1) , TestText varchar(100) NOT NULL , ..... ) the parameters in the IDENTITY are Identity Seed and Increment. If you use IDENTITY(1000, 3) your ID will start at 1000 and the next column will be 3 units bigger as in: 1000 ,1003 ,1006 ,1009 , etc... I could be, anyway, switching the places, maybe the first place is for the incrementals and the second one for the seed. If it doesn't work right, please try it this other way. GOOD LUCK Quote:
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > SQL Server 2000 - Force primary ID |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|