如何使用SQL Server Management Studio将Blob插入数据库 [英] How to insert a blob into a database using sql server management studio
问题描述
如何轻松将blob插入varbinary(MAX)
字段?
How can I easily insert a blob into a varbinary(MAX)
field?
例如:
我要插入的内容是:c:\ picture.png
该表是mytable
该列是mypictureblob
这个地方是recid = 1
thing I want to insert is: c:\picture.png
the table is mytable
the column is mypictureblob
the place is recid=1
推荐答案
您可以在SQL Server Management Studio中使用T-SQL(尤其是使用OPENROWSET命令)将其插入varbinary(max)字段中.
You can insert into a varbinary(max) field using T-SQL within SQL Server Management Studio and in particular using the OPENROWSET commmand.
例如:
INSERT Production.ProductPhoto
(
ThumbnailPhoto,
ThumbnailPhotoFilePath,
LargePhoto,
LargePhotoFilePath
)
SELECT ThumbnailPhoto.*, null, null, N'tricycle_pink.gif'
FROM OPENROWSET
(BULK 'c:\images\tricycle.jpg', SINGLE_BLOB) ThumbnailPhoto
请参阅以下文档,以获取良好的示例/演练
Take a look at the following documentation for a good example/walkthrough
请注意,在这种情况下,文件路径是相对于目标SQL Server的,而不是相对于运行此命令的客户端的.
Note that the file path in this case is relative to the targeted SQL server and not your client running this command.
这篇关于如何使用SQL Server Management Studio将Blob插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!