[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

create constant unique ID from three columns

Posted on 2014-02-07
5
Medium Priority
?
363 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 66

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 2000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

649 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