SQL Server 2005/2008: Insert a File in an varbinar

2019-03-14 23:43发布

Is it possible to insert a file in a varbinary(max) column in Transact-SQL? If yes, I would be very please to have a code snippet to at least give me an idea how to do that.

Thanks

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-03-15 00:06

It's so easy - once you know it! :-) Found this on Greg Duncan's blog a while ago:

INSERT INTO YourTable(YourVarbinaryColumn)
    SELECT * FROM 
    OPENROWSET(BULK N'(name of your file to import)', SINGLE_BLOB) AS import

And here's the MSDN library documentation on it.

Marc

查看更多
登录 后发表回答