August 25, 2016 at 9:22 am
Hi,
I have a text example given below :
SPIT10IHOPIGACSystem
SPMGS2IHOPIForecastingandPlanningProcess
I need SPIT10IHOPIGACSystem to be converted to a UNIQUEIDENTIFIER (8-4-4-4-12) characters
Desired result :SPIT10IH-OPIG-ACSy-stem-xxxxxxxxxxx -- add training x if not enough characters
I need SPMGS2IHOPIForecastingandPlanningProcess
to be converted to a UNIQUEIDENTIFIER (8-4-4-4-12) characters
Desired result :SPMGS2IH-OPIF-orec-asti-ngandPlannin --Trim characters if more than required
Thanks,
PSB
August 25, 2016 at 9:39 am
What have you tried so far?
What problems did you encounter?
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
August 25, 2016 at 9:49 am
The field where I am trying to insert is a UNIQUEIDENTIFIER and I am receiving the following error :
Conversion failed when converting from a character string to uniqueidentifier
August 25, 2016 at 9:54 am
Phil, do we currently have a full moon? :w00t:
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
August 25, 2016 at 9:54 am
UNIQUEIDENTIFIER only permits hexadecimal digits, and your strings contain many non-hexadecimal characters.
Exactly what is the goal of turning strings into UNIQUEIDENTIFIERS like this?
Cheers!
August 25, 2016 at 10:00 am
I need to insert new rows into a table with fake UIDs . I was thinking of using this string to generate UID . How else can I auto generate UID ?
August 25, 2016 at 10:12 am
Got it!
ALTER TABLE Table1 ADD CONSTRAINT DF_UID DEFAULT (NEWID()) FOR PUID;
Thanks for the pointers.
August 25, 2016 at 10:18 am
Alvin Ramard (8/25/2016)
Phil, do we currently have a full moon? :w00t:
A very ordinary moon currently, it would seem 🙂
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
August 25, 2016 at 12:02 pm
The field {columns are not fields} where I am trying to insert is a UNIQUEIDENTIFIER and I am receiving the following error
Conversion failed when converting from a character string to uniqueidentifier
The purpose of GUID and UUID is to locate something that is external to the database. It is never intended for internal use inside the schema. These are hexadecimal numbers that are long enough to be unique and they can be created by an algorithm.
What are you actually trying to do? Why would you think that a string can be converted into a GUID? Were you looking for some kind of hashing algorithm?
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
August 25, 2016 at 12:20 pm
CELKO (8/25/2016)
... The purpose of GUID and UUID is to locate something that is external to the database. It is never intended for internal use inside the schema. ...
Oh really? Never? I think I learned something new today. 😉
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply