How to insert binary data into sql server using SSMS How to insert binary data into sql server using SSMS sql-server sql-server

How to insert binary data into sql server using SSMS


Found the answer:

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

eg

Update myTableset 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


Try this:

INSERT INTO Table (field1) VALUES (0xABCDEF)

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


I found no way to upload/download binary file from SSMS GUI without script.

So I switch to MySQL with Workbench. From their table editor, for a BLOB column, in the context menu, there are Load Value From File... and Save Value To File... options.