SQL Server 2005/2008:在Transact-SQL的varbinary(max)列中插入文件
问题描述:
是否可以在Transact-SQL的varbinary(max)列中插入文件?如果是的话,请提供一个代码片段,至少可以让我知道如何做到这一点.
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.
谢谢
答
这很容易-只要您知道! :-)在 Greg Duncan的博客中找到了前一段时间:
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
这是 MSDN库文档.
马克