Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server binary
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 6-Feb-12 10:08am
RDBurmon9.1K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Comments
Rahul Dhoble at 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 ?
djj55 at 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)

  Print Answers RSS
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 6 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100