Solved

create constant unique ID from three columns

Posted on 2014-02-07
5
353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39843218
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 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 39843219
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
ID: 39843231
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
ID: 39843306
will the hashbyte function be sufficient in doing this?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39844628
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

730 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