question

askmlx121 avatar image
askmlx121 asked

can we able to convert varbinary to string???

can we able to convert varbinary to string???
nvarcharvarchar
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

JohnM avatar image
JohnM answered
Yes. CREATE TABLE #test (NAME VARBINARY(100)) GO INSERT INTO #test (name) values (CAST('john' AS VARBINARY(100))) GO SELECT *,CAST(name AS VARCHAR(100)) FROM #test GO Data Type Conversions - http://msdn.microsoft.com/en-us/library/ms191530.aspx Hope this helps!
2 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Also, I just noticed that this might be related to this post: http://ask.sqlservercentral.com/questions/95108/convert-varbinary-to-varchar-it-works-in-select-bu.html If that is the case, it would be better to move this question into that thread so that we don't have multiple versions of the same question running around.
0 Likes 0 ·
I'll also add that it would depend on what the data that is contained within the varbinary column. If you have attachments like PDF's, it won't convert nicely.
0 Likes 0 ·