Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

varbinary to literal varchar copy in SQL Server 2005

How can I get from this SQL Server varbinary:

0x63C34D6BCAD555EB64BF7E848D02C376

To this varchar?

'63C34D6BCAD555EB64BF7E848D02C376'
like image 458
codeulike Avatar asked Jun 21 '11 11:06

codeulike


1 Answers

declare @B varbinary(max) = 0x63C34D6BCAD555EB64BF7E848D02C376
declare @C varchar(35)

set @C = stuff(upper(sys.fn_varbintohexstr(@B)), 1, 2, '')

select @C

Result:

63C34D6BCAD555EB64BF7E848D02C376
like image 125
Mikael Eriksson Avatar answered Oct 20 '22 20:10

Mikael Eriksson