Monday, March 19, 2012

Hexadecimal String

Hi,

I want to convert a UNIQUEIDENTIFIER to a VARCHAR, but I don't want to convert it to a varchar with this format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; I want to convert it to a varchar representing my uniqueindentifier with a hexadecimal number 0xnnnnnnn...
Anybody knows if this is possible, or will I have to do it manipulating each character in the varchar

Thanks,

FedericoDepending on exactly what you want, there are two ways to get there... THe simple answer is to use:SELECT Cast(myGUID AS VARBINARY(20)) -- 20 is overkill, better safe than sorryIf that isn't sufficient for your needs, then a small UDF will allow you as much flexibility as you know how to code!

-PatP

No comments:

Post a Comment