Solved

create constant unique ID from three columns

Posted on 2014-02-07
5
342 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

863 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

19 Experts available now in Live!

Get 1:1 Help Now