SQL Server - How to insert into Varbinary(Max) column?(SQL Server - 如何插入到 Varbinary(Max) 列中?)
问题描述
我有一张如下所示的表格.我真的不想创建一个 C# 应用程序来将行插入到这个表中,如果我可以避免的话,因为 VarBinary 列.我的目的是在此列中存储一个 Crystal 报表 .RPT 文件.是否有我可以执行的 T-SQL 语句来将行插入/更新到此表中,并包含一个 .RPT 文件?
I have a table that looks as follows below. I don't really want to create a C# application to insert rows into this table, if I can avoid it, because of the VarBinary column. My intent is to store a Crystal report .RPT file in this column. Is there a T-SQL statement I can execute to insert/update rows into this table, and include an .RPT file?
CREATE TABLE [Report].[MesReport](
[MesReportID] [int] IDENTITY(1,1) NOT NULL,
[ParentID] [int] NOT NULL,
[ReportTitle] [nvarchar](80) NOT NULL,
[ReportName] [nvarchar](80) NOT NULL,
[DatabaseServer] [nvarchar](80) NOT NULL,
[DatabaseName] [nvarchar](50) NOT NULL,
[Login] [nvarchar](80) NOT NULL,
[ReportFile] [varbinary](max) NULL,
推荐答案
你可以把它变成一个像
DECLARE @VB varbinary(max)
SELECT @VB =BulkColumn FROM OPENROWSET(BULK
N'C:\YourReport.rpt', SINGLE_BLOB) AS Document
然后您可以在插入语句中使用
that you can then use in an insert statement
这篇关于SQL Server - 如何插入到 Varbinary(Max) 列中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server - 如何插入到 Varbinary(Max) 列中?
基础教程推荐
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
