Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Clr Function

Author  Topic 

josephj1989
Starting Member

7 Posts

Posted - 2010-05-22 : 16:14:56
Hi
I wanted a function to find the greatest of a list of String values passed in.
I want to invoke it as Select greatest('Abcd','Efgh','Zxy','EAD') .It should return Zxy.The number of parameters is variable.
So I wrote a very simple CLR function (Vs2008) and tried to deploy it.
See below

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;

}
};

But when I try to compile or deploy it I get the following error
Cannot find data type SqlString[].

Is it possible to satisfy my requirement using SQL CLR ?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-24 : 09:52:04
Have you tried String[] instead of SqlString[]

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

josephj1989
Starting Member

7 Posts

Posted - 2010-05-24 : 12:19:14
quote:
Originally posted by madhivanan

Have you tried String[] instead of SqlString[]

Madhivanan

Failing to plan is Planning to fail




No you in this circumstance , to be callable from SQL as a function we have to use SqlString - not Sring

thanks
Go to Top of Page

zstarsales04
Starting Member

20 Posts

Posted - 2010-05-25 : 02:37:49
spam removed
Go to Top of Page
   

- Advertisement -