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 |
|
aiken
Aged Yak Warrior
525 Posts |
Posted - 2006-07-09 : 18:15:55
|
| I've got a good one here. I've got a table with an identity column, and I need to make sure that the identity value mod some number (say, 123) will never be zero.I see two possible approaches: an after trigger that checks the inserted identity value (there will never be more than one row inserted at once), and if that value mod 123 = 122, insert a bogus row and then delete it. Or, ditch the identity column and come up with a function to get the next "identity" value.Both solutions are ugly. Anyone see a better one?-b |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-07-09 : 18:58:25
|
| I have to ask. Why is this a requirement?Both of the things you suggest will not scale up very well.CODO ERGO SUM |
 |
|
|
aiken
Aged Yak Warrior
525 Posts |
Posted - 2006-07-09 : 19:09:29
|
| Yeah, it's ugly, I know.The issue is that the front end is going to be reserving those numbers for some special operations. Yes, it's weird, but I have to live with it.-b |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-07-09 : 20:36:17
|
| Review what the front end is doing? Maybe get it to use negative numbers for it's entries.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|