Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All ,

I have one table called which has one binary(32) column.

I need to convert the binary column data into human readable format

for example
One of row having below binary data
0x0000000000000100000000000000000000000000000000000000000000000000

The actual string is (Monday)

How can I write sql statement so that it will return me "Monday" by convert above binary values.

Above is just an example but it can be any binary values like (Monday,Tuesday , Wednesday , Monday and friday , Monday and Sunday ETC..)

Thanks in advance.
Posted

1 solution

Google is our friend.

Have you tried
CAST(bin AS VARCHAR(50))
where bin is your column. Note if this is encrypted you will not be able to do this.
 
Share this answer
 
v2
Comments
RDBurmon 7-Feb-12 1:35am    
I tried this
DECLARE @Table1 AS TABLE(BinValue BINARY(64))

INSERT INTO @Table1 Values(0x0000000000000100000000000000000000000000000000000000000000000000)

SELECT top 1 CAST(BinValue AS VARCHAR(50)) FROM @Table1


But it return empty instead of "Monday"

Help me ?
Corporal Agarn 7-Feb-12 6:47am    
Try INSERT INTO @Table1 SELECT CAST('Monday' AS BINARY)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900