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模板网!
我应该使用什么 SQL Server 数据类型来存储字节 What SQL Server Datatype Should I Use To Store A Byte[](我应该使用什么 SQL Server 数据类型来存储字节 [])
解释 SQL Server 中 sys.objects 中的类型代码Interpreting type codes in sys.objects in SQL Server(解释 SQL Server 中 sys.objects 中的类型代码)
Typeorm .loadRelationCountAndMap 返回零Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
MS SQL:ISDATE() 是否应该返回“1"?什么时候不能MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否应该返回“1?什么时候不能投射为日期?)
将一天的名称转换为其整数表示Converting the name of a day to its integer representation(将一天的名称转换为其整数表示)
如何在 SQL Server 中将 nvarchar m/d/yy 转换为 mm/dd/yHow to convert nvarchar m/d/yy to mm/dd/yyyy in SQL Server?(如何在 SQL Server 中将 nvarchar m/d/yy 转换为 mm/dd/yyyy?)