SQL CLR 聚合参数
以下是使用 SqlUserDefinedAggregate
的示例:http://msdn.microsoft.com/en-us/library/91e6taax(v=vs.80).aspx
这允许您执行以下操作:
SELECT LastName, COUNT(LastName) AS CountOfLastName, dbo.CountVowels(LastName) AS CountOfVowels
FROM Person.Contact
GROUP BY LastName
ORDER BY LastName
我如何将其转换为 dbo .CountLetters(LastName, 'listOfLetters')?换句话说,如何在聚合值时获取额外的参数?使用常规 CLR 函数这很容易,但我不知道如何在这里做到这一点。谢谢!
Here is an example of using a SqlUserDefinedAggregate
: http://msdn.microsoft.com/en-us/library/91e6taax(v=vs.80).aspx
Which allows you to do:
SELECT LastName, COUNT(LastName) AS CountOfLastName, dbo.CountVowels(LastName) AS CountOfVowels
FROM Person.Contact
GROUP BY LastName
ORDER BY LastName
How could I convert this to dbo.CountLetters(LastName, 'listOfLetters')
? In other words, how can I take an extra parameter when aggregating values? This is easy with a regular CLR function, but how to do it here escapes me. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取决于您运行的版本。对于 SQL Server 2005,您不能这样做,因为输入仅限于单个参数。对于 2008 年,请参阅本文了解示例。
Depends on what version you're running. For SQL Server 2005 you can't as the input is restricted to a single parameter. For 2008, see this article for an example.