tsql - Concatenating BINARY value to NVARCHAR string -


i have variable of binary type , sending value function create dynamic query want value concatenated , facing error-

here code -

declare @bin binary =0x000002a2000001bc0001         ,@sql nvarchar(max) select @sql = 'select ' + @bin + 'from test'  select @sql  

i following error when run above code -

msg 402, level 16, state 1, line 3 data types varchar , binary incompatible in add operator.

i need concatenation , don't want binary converted string rather value itself. have searched extensively , haven't been able proper result. closest came link http://www.sqlservercentral.com/forums/topic613703-338-1.aspx.

any on how this? have tried cast , convert no avail.

please change code following , check hope helps.

sql:

declare @bin binary(10)=0x000002a2000001bc0001,@sql nvarchar(max) select @sql = 'select ' + convert(nvarchar(max), @bin, 1) + ' test' select @sql  

this returns original values of binary in query.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -