SujithTee
SujithTee

Reputation: 245

Convert binary to varchar

I need to change the binary output to varchar(string), but it must same as to be the binary output. But while converting the binary(hex) value to varchar, empty set will be returned. Kindly help me.

E.x

If this is my binary value 0x24000000008B0100000000.

I need the same 0x24000000008B0100000000 output after converting it into string.

Upvotes: 3

Views: 16988

Answers (3)

Fadi Nouh
Fadi Nouh

Reputation: 354

this also works for me :

SELECT CONVERT(VARCHAR(1000), varbinary_val, 1);

just change your value with varbinary_val

Upvotes: 3

Esteban P.
Esteban P.

Reputation: 2809

should work like:

DECLARE @a BINARY(20) = 0x24000000008B0100000000
SELECT  CONVERT(varchar(max),@a,1), @a

Upvotes: 0

Kapil
Kapil

Reputation: 987

declare @val binary(20)
set @val=0x24000000008B0100000000

select @val, CONVERT(varchar(max),@val,1)

Upvotes: 10

Related Questions