August 25, 2005 at 1:37 pm
Hi,
Is it possible to set an autoincrement identity column a range value says from (1-999)?
August 25, 2005 at 1:44 pm
yes - you can create the column as IDENTITY(int, 1,1)...but what do you want to do when you reach 999 ?!?!
**ASCII stupid question, get a stupid ANSI !!!**
August 25, 2005 at 1:46 pm
set the identity as (1,1) as usual. Then add a check constraint (Id >=1 and Id <=999)
August 25, 2005 at 1:55 pm
an identity column is used to get a unique value for the row; in your case, you are looking for something that does not uniquely identify the row/field.
i think it would be eser in your case to leave an indentity in place, and then select the modulus for the row to group it into your 1000 increments:
select uniqueID,(uniqueID % 1000) as uniqueID,somecolumn as description from sometable
999 999 someval999
1000 0 someval1000
1001 1 someval1001
Lowell
August 25, 2005 at 2:01 pm
I think he needs to keep the table under 1000 rows. I already used that technic before and it works well. An instead of insert trigger can also do the same job (assuming he needs to do the same thing as me).
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply