Sunday, February 12, 2012

Clustered Index Increment

I have a clustered index (Group_ID, Member_ID)
How do I set Member_ID to be an autoincrement field ( each should start at 1 for each Group_ID).

Can SQL Server autoincrement feature do this?

If not is the best way then use a stored procedure to get the max member_ID for that Group, increment it with 1 and the assign it to the new member_ID?having a clusted index has no bearing on an autoincrement field

SQL server supports an Identity property for integer columns. it supports an Identity Seed (the starting number), and it supports an identity increment (default is 1).|||My problem is I need to start the identity at 1 for each group|||Identity columns are constrained to be unique.

if your going to repeat values, then you cant use an identity column.

No comments:

Post a Comment