Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase ««12

Maintaining the Value of My Primary Key Question Expand / Collapse
Posted Monday, November 25, 2013 3:21 PM


Group: General Forum Members
Last Login: Friday, October 23, 2015 4:25 PM
Points: 153, Visits: 441
Scott's suggestion looks good.

What I was looking for, and I am probably not drawing a decent picture, is a way to get a value out of multiple columns so that I will have a distinct value for each field and if I have to reload the data, the values will not change.

What I started playing with is concatenating the four columns and converting them to varbinary and then converting that to varchar(36) with style 2.
I'm at home now so I don't have the script I was working with. I'll update the post tomorrow with what I wrote.
Anways, That gives me a value that is based off of the four columns. I was able to do it on the 1.8 million record table I was working with and then assigned that column as the PK. I did not have any PK violations, so I am getting a unique value. I still have some more playing around with it to see if this method is of any value.
Post #1517485
Posted Monday, November 25, 2013 4:06 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Wednesday, November 30, 2016 3:59 PM
Points: 660, Visits: 1,444
I think Scott's suggestion is the best. It's similar in concept to what we do in our accounting software. Another option would be some sort of hashing routine but with up to 80 chars seems like it would be problematic at best.
Post #1517490
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse