Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BLOB to String, SQL Server

I have a text string stored as a BLOB data type in a database. I want to extract it by an SQL select query, but I have problems converting/casting from BLOB to readable text.

I've tried e.g.

select convert(nvarchar(40),convert(varbinary(40),BLOBTextToExtract))
from [NavisionSQL$Customer]

I guess I need something similar, but I can't figure out exactly what I need to do the conversion. Can somebody please give me some directions?

Regards

like image 731
user822448 Avatar asked Aug 02 '11 11:08

user822448


People also ask

Can we convert BLOB to string in SQL?

In order to convert BLOB to TEXT, we will use the CONVERT statement.

How do I view BLOB data in SQL Server?

To read BLOB data, you need to use the SqlDataReader class of ADO.NET. The use of SqlDataReader class to read BLOB data can be best understood with an example. You will develop a simple application that manages photos stored in a SQL Server database.


1 Answers

The accepted answer works for me only for the first 30 characters. This works for me:

select convert(varchar(max), convert(varbinary(max),myBlobColumn)) FROM table_name
like image 172
chris Avatar answered Sep 26 '22 06:09

chris