Insert image into SQL Server

78,467

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
Share:
78,467
mitsu
Author by

mitsu

Updated on July 29, 2022

Comments

  • mitsu
    mitsu almost 2 years

    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.

  • mitsu
    mitsu about 10 years
    but if i put url of the image for exemple in my DD 'D' in a folder ' myimages' , and when the user take this application in the futur he will have a problem whith the path of the image no?
  • abdou_dev
    abdou_dev over 3 years
    what if is stored procedure ? how can I do that?