Search code examples
sql-serverimagessms

How to insert binary data into sql server using SSMS


Is there a way to insert binary data into sql server directly from SQL Server management studio?


Solution

  • Found the answer:

    SQL Server has an "OPENROWSET" command that accepts a filepath.

    eg

    Update myTable
    set Image = (
    SELECT *
    FROM OPENROWSET(BULK N'C:\image.png', SINGLE_BLOB) test)
    where ImageID = 1 
    

    Source: http://shortfastcode.blogspot.com/2009/12/insert-binary-data-like-images-into-sql.html