Home » » The TSQL to insert an image/blog

The TSQL to insert an image/blog

I recently needed this syntax.

If you want to insert a local file into a database image field (varbinary(max) field) then this is the syntax:

CREATE TABLE MyTable 
(id int, image varbinary(max))

INSERT INTO MyTable
SELECT 1
,(SELECT * FROM OPENROWSET(
BULK 'C:\file.bmp', SINGLE_BLOB) as x )


0 comments:

Post a Comment

Popular Posts

Powered by Blogger.
.comment-content a {display: none;}