Solved

create constant unique ID from three columns

Posted on 2014-02-07
5
338 Views
Last Modified: 2014-02-18
I have a large contact table that gets refreshed every quarter.  I am trying to assign a unique identifier to the field that, unlike newid(), will remain constant with updates. I know I can build a string from things like firstname, lastname, address,city, state, zip, but what would be the best way to convert that string concatenation into an identifier that will be constant with every update (I know when people move it will change the id, but that is not of concern for me right now).

Thanks for the help.
0
Comment
Question by:gwarcher
5 Comments
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
Give us a before-and-after data mockup of what you're trying to pull off here, with emphasis on any variation in 'every update'.
0
 
LVL 33

Accepted Solution

by:
paulmacd earned 500 total points
Comment Utility
You could use a unique number aside from the ID (which, i presume, you think will change between database moves).  Create an integer column (let's call it UniqID) and seed it with values from whatever ID column exists now.  

Then create a process where you get MAX(UniqID) + 1 and insert that value into the column whenever you add a new record.  The number will always be unique, even after a database move.  Your only worry is if there's a great deal of sudden activity when adding new records.
0
 

Author Comment

by:gwarcher
Comment Utility
ok I will clarify a little more, lets say I have the following

firstname   lastname      idnumber
robert         smith           12345
jane            doe               54321

I can't use the idnumber in all cases as the uniqueID because the data I get will sometimes have errors in it where there will be a duplicate idnumber.  I catch those later but for purposes of parsing through the data I would like to combine the firstname, lastname and idnumber columns to create a unique id that will carry over with each quarterly update.

thanks,
0
 

Author Comment

by:gwarcher
Comment Utility
will the hashbyte function be sufficient in doing this?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
will the hashbyte function be sufficient in doing this?
Not really.  If the data is duplicated, using the HASHBYTE() function will simply give you the same value each time.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now