Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 converting weird unique reference

Author  Topic 

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2010-08-12 : 03:54:12
I've just exported some relational tables from an old CRM database called Telemagic.

the unique identifier contains some really whacky characters and i'm convinced this is messing up my import routines.

Is there a way to convert the value below to something else more readable?

TME(+q¦

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2010-08-12 : 03:55:19
I dont believe it - even posting it to here changes the characters.
that thing at the end is like a series of dots in a square on the actual field
Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2010-08-12 : 05:52:30
I've just found i can do this

select contactid , convert(varbinary, contactid ) as converted, CAST(contactid as varbinary) from level11

and it converts the horrible string to a long identifier.
But I am ashamed to admit - i don't really know what i'm doing here.
Will these new values be unique?
Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2010-08-12 : 06:15:58
cast(CAST(contactid as varbinary) AS int)
seems to convert the long number create dby varbinary into a smaller number.

please someone...anyone.... tell me am i heading in the right direction...??? Please???
Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2010-08-12 : 06:36:31
This hasn't worked I need some help.

i need to convert "TME(*«@" this to a sensible unique identifier
Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2010-08-12 : 06:51:16
how about this..


select cast(ASCII(SUBSTRING(CONTACTID,1,1)) as varchar) + cast(ASCII(SUBSTRING(CONTACTID,2,1))as varchar) + cast(ASCII(SUBSTRING(CONTACTID,3,1))as varchar)+

cast(ASCII(SUBSTRING(CONTACTID,4,1)) as varchar) + cast(ASCII(SUBSTRING(CONTACTID,5,1))as varchar) + cast(ASCII(SUBSTRING(CONTACTID,6,1))as varchar)+

cast(ASCII(SUBSTRING(CONTACTID,7,1))as varchar),


contactid

from Level11
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-08-12 : 11:51:26
Unfortunatly, I don't know anything about Telemagic. However, if I was you, and you data matters, you might checkout their website/forums to get an understanding of what that field is/represents. Otherwise, you are just guessing and that can't be good for trying to create a properly constrained database.
Go to Top of Page
   

- Advertisement -