How to insert a blob into a database using sql server management studio(如何使用 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 插入到数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 sql server management studio 将 blob 插入到数据库中
基础教程推荐
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- 在多列上分布任意行 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
