将查询结果传递给 CLR SqlFunction

发布于 2024-11-29 10:00:05 字数 1064 浏览 0 评论 0原文

我有一个存储过程,需要将结果集从另一个存储过程传递到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹微笑 2024-12-06 10:00:05

请参阅此问题将表作为参数传递给 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文