Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQLServer and Incremental Values
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00888511
Message ID:
00888535
Views:
9
>I have a question about Incremental values. I am still getting into SQL Server but I had this thought.
>
>Can a value be incremented within a certain boundary and then be reset to 1?
>
>In other words, I have a table with:
>
>Column A Column B Column C
>D001 B5 1
>D001 B5 2
>D001 B5 3
>D002 B5 1
>D003 B3 1
>
>Where Column C is an incrementing column that is dependent on the combined value of Columns A and B. Is this possible in SQL Server? Or do I need to create either a function/stored proc or handle it in my client?

Without doing some experimentation, it seems to me that you could do this with a combination of identity columns and a trigger on the table. AFAIK, there is no restraint on ID columns requiring the value to be unique. So, the logic in your trigger can reset the ID back to 1 whenever the condition is appropriate.
Dan LeClair
www.cyberwombat.com
SET RANT ON - The Wombat Blog

Life isn’t a morality contest and purity makes a poor shield. - J. Peter Mulhern
Disclaimer: The comments made here are only my OPINIONS on various aspects of VFP, SQL Server, VS.NET, systems development, or life in general, and my OPINIONS should not be construed to be the authoritative word on any subject. No warranties or degrees of veracity are expressed or implied. Void where prohibited. Side effects may included dizziness, spontaneous combustion, or unexplainable cravings for dark beer. Wash with like colors only, serve immediately for best flavor.
Previous
Reply
Map
View

Click here to load this message in the networking platform