Tuesday, August 27, 2013

Insert / Update image into SQL Server database using query (not front end application)

Using Insert

INSERT INTO [table]
            (COLUMN)
SELECT *
FROM   OPENROWSET(BULK N'Path to file', single_blob) AS [File] 


Using Update

UPDATE [table]
SET    [column] = (SELECT *
                   FROM   OPENROWSET(BULK N'Path to file', single_blob) AS
                          [File])
--Conditions if any

No comments:

Post a Comment