Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving data stored as image as string in SQL Server 2005

I need to retrieve an xml file stored as image data in SQL Server.

I am using this query -

select 
    convert(varchar, convert(binary, zd.validcontent)) 
from 
    zonedata zd
join 
    contentitem ci on zd.itemid = ci.itemid
where 
    id = @dpathid 

I get text but but the result returns only a small portion of the xml file -

<?xml version="1.0" encoding="

Please help. Thanks.

like image 781
Lucky Luke2 Avatar asked Jul 11 '13 07:07

Lucky Luke2


People also ask

What datatype is used for image in SQL Server?

The IMAGE data type in SQL Server has been used to store the image files. Recently, Microsoft began suggesting using VARBINARY(MAX) instead of IMAGE for storing a large amount of data in a single column since IMAGE will be retired in a future version of MS SQL Server.

How do I open an image in SQL?

How to view images stored in your database Start SQL Image Viewer and connect to your database. For SQL Server databases, tables containing blob columns will be highlighted in green in the list of database objects. Write the query to retrieve your images, and execute the query.

Can I save image in SQL?

To save image in SQL Server database table in binary format, the easiest method is to execute an SQL OPENROWSET command with BULK and SINGLE_BLOB options. Let's assume that your SQL Server database administrator creates database table named DatabaseImageTable using following SQL create script.

How do you find Comma Separated Values in SQL?

To check if value exists in a comma separated list, you can use FIND_IN_SET() function. Now you can insert some records in the table using insert command. Display all records from the table using select statement.


1 Answers

Possible this be helpful for you -

SELECT CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), zd.validcontent))
FROM zonedata zd
JOIN contentitem ci ON zd.itemid = ci.itemid
WHERE ID = @dpathid
like image 145
Devart Avatar answered Oct 11 '22 23:10

Devart