Convert varbinary to Text

Posted by Suneel161 under Sql Server on 12/4/2012 | Points: 10 | Views : 11427 | Status : [Member] | Replies : 3
Hi,

i am saving data in table varbinary format.how to convert varbinary data to text.




Responses

Posted by: Krv on: 12/4/2012 [Member] Starter | Points: 25

Up
0
Down
declare @b varbinary(max)
set @b = 0x5468697320697320612074657374

select cast(@b as varchar(max))

Thanks,
R.Vasanth
MCTS(SQL Server & BI)
http://bigdatatech.blogspot.com

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/6/2012 [Member] Bronze | Points: 25

Up
0
Down
declare @Hi varchar(100)
declare @b varbinary(max)
set @b = 0x48656C6C6F20746F20446F6E6E657466756E6461
select @Hi=cast(@b as varchar(max))
print @Hi

Thanks
Pavan Kumar
Mark Answer if this fits the need

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandhyab on: 12/11/2012 [Member] Starter | Points: 25

Up
0
Down
Using Cast
declare @b varbinary(max)

set @b = 0x5468697320697320612074657374

select cast(@b as varchar(max))

Using convert
DECLARE @bin VARBINARY(MAX)

SET @bin = 0x5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8

SELECT CONVERT(VARCHAR(MAX), @bin, 2)


Thanks & Regards



Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response