J
J
JoraInTheSky2017-07-18 22:51:33
Transact SQL
JoraInTheSky, 2017-07-18 22:51:33

add image to sql table

There is a database with the name ProductPicture 48d2e39547e544df926dcc296c387500.JPG
, you need to fill in the Picture field with a request, which contains a binary array of the picture. I'm trying with this query

UPDATE ProductPicture SET ProductPicture.Picture =  CONVERT(varbinary(MAX), 'C:\1.jpg')

but this is followed by a message about a successful query, but the database is still empty.
Question: how can I load a file (picture) into a cell from sql managemet?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2017-07-19
@JoraInTheSky

OPENROWSET .
Question author's solution:

UPDATE PictureProduct 
SET Picture = 
      (SELECT * FROM OPENROWSET(BULK N'C:\1.jpg', SINGLE_BLOB) AS image)
WHERE Id = 6

INSERT INTO PictureProduct (Id, IdProduct, Picture) 
SELECT 8, 4, BulkColumn 
FROM Openrowset( Bulk 'C:\2.jpeg', Single_Blob) as image

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question