Wednesday, May 22, 2013

How to insert image into Image data type in SQL Server

Create table with some columns like

create table tblimages (ImageId int,photo image,Model varchar(50))
Then insert data into table like below

insert into tblimages  values(1,(select BulkColumn from openrowset(Bulk 'ImagePath',single_blob) as img),'ModelName')

Here in ImagePath place you have to specify the image path like  'D:\img\image.jpg'
Now the image will convert to Byte form and store in Photo column in table tblimages

No comments:

Post a Comment