SQL Server 2005/2008: Insert a File in an varbinary(max) column in Transact-SQL

[亡魂溺海] 提交于 2019-12-20 11:51:31

问题


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:


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



来源:https://stackoverflow.com/questions/1212494/sql-server-2005-2008-insert-a-file-in-an-varbinarymax-column-in-transact-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!