SQL Server 2005/2008:在Transact-SQL的varbinary(max)列中插入文件

时间:2022-08-28 09:25:02

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.

是否可以在Transact-SQL的varbinary(max)列中插入文件?如果是的话,我会很高兴有一个代码片段,至少让我知道如何做到这一点。

Thanks

谢谢

1 个解决方案

#1


29  

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

它很容易 - 一旦你知道它! :-)刚才在Greg Duncan的博客上找到了这个:

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.

这是关于它的MSDN库文档。

Marc

渣子

#1


29  

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

它很容易 - 一旦你知道它! :-)刚才在Greg Duncan的博客上找到了这个:

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.

这是关于它的MSDN库文档。

Marc

渣子