Click here to Skip to main content
15,881,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Convert Varbinary to Nvarchar in Select Table?


select id,cast(Img as nvarchar) from Tbl_Info

or


select id,convert(nvarchar,Img,'') from Tbl_Info,

is not work
Posted
Comments
PIEBALDconsult 8-Nov-14 10:22am    
You didn't specify a length for the NVARCHAR.
Why would you want to do that anyway? You may have a hard time converting it back again.
If you need to serialize the image, I'd do that in code, not in the database.

1 solution

Like this:

SQL
SELECT
    Id,
    CAST(CAST(img AS BINARY) as NVARCHAR(1000))
FROM
    Tbl_Info
 
Share this answer
 
Comments
[no name] 8-Nov-14 10:23am    
It is a strange request which never could be solved 100%. But you gave a solution which works under some conditions, so my 5.
Manas Bhardwaj 8-Nov-14 10:24am    
thx Bruno!

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