I want to insert in a table an (image , id, Code)
but I don't know how to do this .
What I am looking for is how to insert an image not url.
1) Bring up SQL Server Management Studio. 2) Connect, and open the database you want to add the image to. 3) Expand the tables, and either add a new table with an appropriate index field, or right click teh table and select design. 4) Add a field called "myImage", and make its datatype "image".
We can't store an image directly into the database. For this we have two solutions: To store the location of the image in the database. Converting the image into binary data and insert that binary data into database and convert that back to image while retrieving the records.
you can try like this
CREATE TABLE ImageTable
(
Id int,
Name varchar(50) ,
Photo varbinary(max)
)
INSERT INTO ImageTable (Id, Name, Photo)
SELECT 1, 'test', BulkColumn
FROM Openrowset( Bulk 'C:\test.jpg', Single_Blob) as image
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