Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To: Convert String of Unknown Length into a Unique Value

Status
Not open for further replies.

campbelt

Programmer
Dec 8, 2007
5
0
0
US
Hello,

I am trying to figure out a way to convert a string of some unknown length into a unique value (INT or NVARCHAR) no longer than 15 characters. Is this possible? Any thoughts or ideas?

I have been exploring various hashing algorithms and the like, btu they all produce values that are too long.

Thank you very much for your time.
 
It really depends on your string length and number of rows you are likely to use. For example if you had a 10 char string, you could populate a table with values 1 through to 99999 and then convert this to a string and add to the 10 char value. Then you would have a 15 char string that was unique upto 99,999 values

etc
1+SMITH = 1SMITH
99+SMITH = 99SMITH
9999+SMITH = 9999+SMITH

Don't know if meets your requirements or not it really depends on what you want to achieve, there are always more than 1 way to do anything in SQL.

Hope that give you some ideas towards a solution
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top