crystalized
Programmer
Hi All,
I am using SQLServer 2000 and am in a position where I need to create a unique numeric value for each record in a table. The table has a GUID as the key, but I need an additional unique value that is an 8 character numeric value.
My plan is to use a SP with something like the following structure
(psuedo-code)
Now I know that if the key value was an identity field I could take the maximum value and do some kind of hash function to create a new value that would be unique. My problem here is that I have a GUID to work from and I am not sure what kind of "hash" function I should use to create that numeric value.
As you see I have already accomodated in my plan for a failure to create a unique value on the first try but I really do not want to make many more than 2 trials, but even more so I do not want to return that error message unless absolutely necessary.
If anyone has any ideas on this it would be very helpful - even if they are just some starting points.
Thanks in Advance Crystal
crystalized_s@yahoo.com
--------------------------------------------------
Experience is one thing you can't get for nothing.
-Oscar Wilde
I am using SQLServer 2000 and am in a position where I need to create a unique numeric value for each record in a table. The table has a GUID as the key, but I need an additional unique value that is an 8 character numeric value.
My plan is to use a SP with something like the following structure
(psuedo-code)
Code:
Generate numeric value
If numeric value is unique
insert numeric value
Else
Change some element of hash function
Regenerate numeric value
If numeric Value is unique
Insert numeric value
Else
Return Error message
As you see I have already accomodated in my plan for a failure to create a unique value on the first try but I really do not want to make many more than 2 trials, but even more so I do not want to return that error message unless absolutely necessary.
If anyone has any ideas on this it would be very helpful - even if they are just some starting points.
Thanks in Advance Crystal
crystalized_s@yahoo.com
--------------------------------------------------
Experience is one thing you can't get for nothing.
-Oscar Wilde