【发布时间】:2010-05-24 05:27:07
【问题描述】:
我想要一个函数来查找传入的字符串值列表中的最大值。
我想从 sql server 调用它作为 Select best('Abcd','Efgh','Zxy','EAD')。 它应该返回 Zxy。 参数的数量是可变的。顺便说一下,它非常类似于 oracle GREATEST 函数。 于是我写了一个很简单的CLR函数(Vs2008)并尝试部署。 见下文
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString Greatest(params SqlString[] p)
{
SqlString max=p[0];
foreach (string s in p)
max = s.CompareTo(max) > 0 ? s : max;
return max;
}
};
但是当我尝试编译或部署它时,我收到以下错误 找不到数据类型 SqlString[]。
是否可以使用 SQL CLR 满足我的要求?
【问题讨论】:
-
为什么一定是CLR函数?
标签: sql-server sqlclr user-defined-functions