CLR UDF returning Varbinary(MAX)(CLR UDF 返回 Varbinary(MAX))
问题描述
SQL CLR 用户定义函数是否可以返回数据类型 varbinary(MAX)?
Is it possible for a SQL CLR User-Defined Function to return the data type varbinary(MAX)?
在它提到的文档中:
标量值函数返回的输入参数和类型可以是 SQL Server 支持的任何标量数据类型,但 rowversion、text、ntext、image、timestamp、table 或 cursor 除外."- 他们没有提到 varbinary,但我不确定...
"The input parameters and the type returned from a scalar-valued function can be any of the scalar data types supported by SQL Server, except rowversion, text, ntext, image, timestamp, table, or cursor." - they don't mention varbinary, but I'm not sure...
我有一些来自 .NET 端的字节数组数据,我需要从 CLR 返回到 SQL Server,并且我试图避免使用来自存储过程的输出参数(这就是我现在正在测试中).
I have some byte-array data from the .NET side that I need to return to SQL Server from the CLR, and I'm trying to avoid having to do it with an output parameter from a stored procedure (this is how I have it working in test now).
谢谢!
推荐答案
如果您将其定义为返回一个 SqlBytes 数据类型,这应该正确映射到 SQL Server 中的 varbinary(MAX).
If you define it as returning a SqlBytes data type, this should correctly map to varbinary(MAX) in SQL Server.
[SqlFunction]
public static SqlBytes Function1()
{
return new SqlBytes(Encoding.UTF8.GetBytes("Hello world."));
}
虽然您也可以使用 SqlBinary 数据类型,如果您通过 Visual Studio 部署,它将映射到 varbinary(8000) 而不是 varbinary(MAX).
Whilst you can also use the SqlBinary data type, if you deploy via Visual Studio, it will be mapped onto varbinary(8000) rather than varbinary(MAX).
这篇关于CLR UDF 返回 Varbinary(MAX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CLR UDF 返回 Varbinary(MAX)
基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
