Hi Tom,

 

So many questions about what you’re trying to do (sounds really odd), but I think the safest for you right now would be to just select the current key and the truncated value out into another table while you take a look at them.

 

Regards,

 

Greg

 

Dr Greg Low

 

1300SQLSQL (1300 775 775) office | +61 419201410 mobile

SQL Down Under | Web: https://sqldownunder.com | About Greg:  https://about.me/greg.low

 

From: Tom P via ozdotnet <ozdotnet@ozdotnet.com>
Sent: Tuesday, 14 March 2023 9:52 AM
To: ozDotNet <ozdotnet@ozdotnet.com>
Cc: Tom P <tompbiz93@gmail.com>
Subject: [OT] "Shrinking" IDs in SQL Server

 

Hello

 

I was hoping some of the SQL experts here could help with a problem I am facing. Currently have covid too so perhaps I'm not thinking clearly...

 

Long story short, is there a way in SQL Server to convert strings (varchars) of any length to exactly 32, keeping uniqueness? It would also be nice if I could convert them back to ensure I haven't lost information.

 

Briefly, the reason I want to do this is my target is varchar(32) but the IDs I am dealing with are made up of composite business keys of larger length. I need to be able to use the current business keys and generate unique 32 character equivalents in a deterministic way.

 

Appreciate any advice.

 

Thanks

Tom