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 |
dwalker79
Yak Posting Veteran
54 Posts |
Posted - 2008-09-22 : 09:48:41
|
I want to be able to reserve a range of rows at the top of a table to be used for new specific entries. At the bottom of the table will exist the old data.Is it possible in SQL Server 2000 to reserver say the top 100 rows for specific entries?Thanks!Dustin |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-22 : 09:54:10
|
yup.a way of doing it is to create an identiy column as pk. make seed value as 101 and incrementer as 1. Now for specific entries use SET IDENTITY_INSERT <tablename> ON and explicitly pass a value <=100 |
 |
|
dwalker79
Yak Posting Veteran
54 Posts |
Posted - 2008-09-22 : 10:14:58
|
So you would suggest adding a brand new column to the table and making it an identity column? What if I already have a primary key on the table? |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-22 : 10:56:27
|
quote: Originally posted by dwalker79 So you would suggest adding a brand new column to the table and making it an identity column? What if I already have a primary key on the table?
is primary key an identity column?if yes, what is the seed and increment? |
 |
|
dwalker79
Yak Posting Veteran
54 Posts |
Posted - 2008-09-22 : 11:01:04
|
No, the existing primary key is not an identitiy column. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-22 : 11:31:14
|
quote: Originally posted by dwalker79 No, the existing primary key is not an identitiy column.
Then you need to create a new identity column. just useALTER TABLE ADD columnName int IDENTITY(101,1)and it will automatically populate existing columns with values starting from 101. For sepecific value you may use values from 1 to 100.Also remember to SET IDENTITY_INSERT tablename ON before inserting specific values and set it to OFF after. |
 |
|
|
|
|