问题描述
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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)