solution for primary key
-
The problem is that i have a primary key whose dbtype is Bigint i dont want to keep auto to generate the primary key in sql2000 table by code and return that value. Then when entering next record increment must be made to the previous number and inserted as a primary key next question is if i delete any resord then how to sort the primary keys in ascending order sas
-
The problem is that i have a primary key whose dbtype is Bigint i dont want to keep auto to generate the primary key in sql2000 table by code and return that value. Then when entering next record increment must be made to the previous number and inserted as a primary key next question is if i delete any resord then how to sort the primary keys in ascending order sas
@@Identity will give you the last identity from an insert statement. and SCOPE_Idendity() will give you the last value in an insert in your current scope. Primary Keys are stored by the database in ascending order, usually, so they will always be sorted. I think what you be asking is for sequential primary keys by changing the identity_seed on a deletion. This is possible with the undocumented SQL 2000 system stored procedures but it is not recommended by MS.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway -
The problem is that i have a primary key whose dbtype is Bigint i dont want to keep auto to generate the primary key in sql2000 table by code and return that value. Then when entering next record increment must be made to the previous number and inserted as a primary key next question is if i delete any resord then how to sort the primary keys in ascending order sas
You should create another column to satisfy your requirements of a contiguous numbering system. A primary key identifies the record and shouldn't change. I wouldn't want to be dealing with Customer#1234 and then send an update to the database, but it turns out my Customer is now #1233 because someone deleted a record while. Customer#1234 (who is now Customer#1233) would be especially annoyed when his shipment of goods gets sent to the old Customer#1235, who is now Customer#1234. Wow. You can see what I'm getting at already!
Mark Churchill Director Dunn & Churchill Diamond Binding: Zero to Data Layer in 3 mins