SQL Server allows storing files. In this article, we learned how to insert a single image file into a SQL Server table using T-SQL.
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".
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.
give this a try,
insert into tableName (ImageColumn)
SELECT BulkColumn
FROM Openrowset( Bulk 'image..Path..here', Single_Blob) as img
INSERTING
REFRESHING THE TABLE
Insert Into FEMALE(ID, Image)
Select '1', BulkColumn
from Openrowset (Bulk 'D:\thepathofimage.jpg', Single_Blob) as Image
You will also need admin rights to run the query.
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