I have the following code that converts Unique-identifier to Binary:
CAST(GUID AS BINARY(16))
which results in this '0x56B3C0955919CD40931F550749A83AF3'
Now, I want to convert this (i.e. the binary string value '0x56B3C0955919CD40931F550749A83AF3'
) to Unique-Identifier.
Any simple way to achieve this?
Uh, just convert it back?
DECLARE @n UNIQUEIDENTIFIER = NEWID();
SELECT @n;
SELECT CONVERT(BINARY(16), @n);
SELECT CONVERT(UNIQUEIDENTIFIER, CONVERT(BINARY(16), @n));
If you have a binary value like 0x56B3C0955919CD40931F550749A83AF3
, stop putting it into quotes when trying to convert it. For example:
SELECT CONVERT(UNIQUEIDENTIFIER, 0x56B3C0955919CD40931F550749A83AF3);
Isn't this the result you're after?
95C0B356-1959-40CD-931F-550749A83AF3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With