开发者

SQL CLR aggregate parameters

开发者 https://www.devze.com 2023-02-07 13:51 出处:网络
Here is an example of using a SqlUserDefinedAggregate: http://msdn.microsoft.com/en-us/library/91e6taax(v=vs.80).aspx

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.Conta开发者_JAVA技巧ct
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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消