Saturday, September 28, 2019

How to store image in SQL Server database table column


Below are the steps to import image file to sql server database

Step 1:

Create table

CREATE TABLE ImageUpload (
   ImageName NVARCHAR(40) PRIMARY KEY NOT NULL
   , ImgFileName NVARCHAR (100)
   , DataFile VARBINARY (max)
   )
GO

Step 2:

Insert record

insert into ImageUpload (ImageName, ImgFileName, DataFile)
select 'NewYearCake','Newyear.jpg',BulkColumn
FROM Openrowset( Bulk 'G:\Image\DSC02319.JPG', Single_Blob) as img


select * from ImageUpload



You can verify whether image got uploaded correctly by using SSRS.
Please visit the below link for more info.


Display Database Images in SSRS Report

No comments:

Post a Comment