如何使用 sql server management studio 将 blob 插入到数据库中 [英] How to insert a blob into a database using sql server management studio

查看:30
本文介绍了如何使用 sql server management studio 将 blob 插入到数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何轻松地将 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 插入 varbinary(max) 字段,尤其是使用 OPENROWSET 命令.

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	ricycle.jpg', SINGLE_BLOB) ThumbnailPhoto

查看以下文档以获得一个很好的示例/演练

Take a look at the following documentation for a good example/walkthrough

使用大值类型

请注意,在这种情况下,文件路径相对于目标 SQL 服务器,而不是您的客户端运行此命令.

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆