将查询结果传递给 CLR SqlFunction
我有一个存储过程,需要将结果集从另一个存储过程传递到 UDF,进而调用 CLR SqlFunction
。我不知道如何将结果集传递到我的 CLR SqlFunction
中。我没有看到表SqlType
,也找不到任何在线示例,也许我搜索不正确?另外,如果您查看传入的最后一个参数,那就是我遇到问题的地方。不知道如何传入结果集。谢谢!
<SqlFunction(DataAccess:=DataAccessKind.Read, SystemDataAccess:=SystemDataAccessKind.Read)> _
Public Function GetMatchedConstituents(ByVal ID As SqlGuid, ByVal CustomID As SqlString,
ByVal KeyName As SqlString, ByVal FirstName As SqlString,
ByVal MiddleName As SqlString, ByVal AddressBlock_Home As SqlString,
ByVal AddressBlock_Business As SqlString, ByVal PostCode_Home As SqlString,
ByVal PostCode_Business As SqlString, ByVal Phone_Home As SqlString,
ByVal Phone_Business As SqlString, ByVal ResultSet As [WhatType? There isnt a SqlTable like I assumed]) As IEnumerable
'do duplicate comparing logic here
End Function
I have a stored procedure that needs to pass a result set from another stored procedure into a UDF, that in turn calls a CLR SqlFunction
. What I can't figure out how to do is how to pass the result set into my CLR SqlFunction
. I don't see a table SqlType
nor can I find any examples online, maybe I am searching incorrectly? Also if you look at the last parameters passed in, that is where I am having problems. Don't know how to pass in the result set. Thanks!
<SqlFunction(DataAccess:=DataAccessKind.Read, SystemDataAccess:=SystemDataAccessKind.Read)> _
Public Function GetMatchedConstituents(ByVal ID As SqlGuid, ByVal CustomID As SqlString,
ByVal KeyName As SqlString, ByVal FirstName As SqlString,
ByVal MiddleName As SqlString, ByVal AddressBlock_Home As SqlString,
ByVal AddressBlock_Business As SqlString, ByVal PostCode_Home As SqlString,
ByVal PostCode_Business As SqlString, ByVal Phone_Home As SqlString,
ByVal Phone_Business As SqlString, ByVal ResultSet As [WhatType? There isnt a SqlTable like I assumed]) As IEnumerable
'do duplicate comparing logic here
End Function
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅此问题将表作为参数传递给 SQLCLR TV-UDF其中包含其他相关信息的链接。简而言之,SQL CLR 目前不支持 TVP。
如果结果集足够小,您可以将其转换为 XML 类型并将其作为参数传递给 SQL CLR 函数 (
SqlXml
)。您还可以让存储过程设置临时表来共享。它很草率,但最终可能是你唯一的选择。
See this question Pass table as parameter to SQLCLR TV-UDF which has links to other related information. In short, TVP is not currently supported in SQL CLR.
If the result set is small enough you could convert it to an XML type and pass that as a parameter to your SQL CLR function (
SqlXml
).You could also have the stored procedures set up temporary tables to share. It's sloppy, but may end up being your only option.