How to insert binary data into sql server using SSMS

27,853

Solution 1

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

Solution 2

Try this:

INSERT INTO Table (field1) VALUES (0xABCDEF)

Where 0xABCDEF is your binary data represented as an hexadecimal sequence.

Share:
27,853
Daniel
Author by

Daniel

Chocolate doesn’t ask questions, chocolate understands.

Updated on July 19, 2020

Comments

  • Daniel
    Daniel almost 4 years

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