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.
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 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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With