Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the easiest way to update an image field with the content of a file

I've a table in MS Sql server with an image field and a file. What is the easiest way to create a T-Sql script that updates the field with the content of the file?

like image 583
MarioH Avatar asked Dec 07 '10 11:12

MarioH


People also ask

Can we write update in view?

You can insert, update, and delete rows in a view, subject to the following limitations: If the view contains joins between multiple tables, you can only insert and update one table in the view, and you can't delete rows. You can't directly modify data in views based on union queries.


1 Answers

UPDATE YourTable
SET BlobColumn = 
    (SELECT  BulkColumn FROM OPENROWSET(BULK  N'C:\YourFile.png', SINGLE_BLOB) AS x)
WHERE ...
like image 113
Martin Smith Avatar answered Sep 18 '22 08:09

Martin Smith