views:

136

answers:

2

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

+1  A: 

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

Daniel
This requires that OPENROWSET is enabled on the server - it is disabled by default.
Ed Harper
+1  A: 

Try this:

INSERT INTO Table (field1) VALUES (0xABCDEF)

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

Rubens Farias