While writing a CLR function Sql Server can we use namespaces ?
namespace SomeName1.SomeName2
{
public static class SomeClass
{
[SqlFunction]
public static SqlString SomeMethod(SqlString input)
{
// ....
}
}
}
If so, then how do we call this function from SqlServer. In other words how do we call CLR functions from SQL Server with namespaces?
Yes, you absolutely can:
CREATE FUNCTION SomeMethod(@input VarChar(200))
RETURNS VarChar(200) WITH EXECUTE AS CALLER AS
EXTERNAL NAME [SomeName1.SomeName2].[SomeName1.SomeName2.SomeClass.SomeMethod]
Where [SomeName1.SomeName2]
in the first part is the assembly as named in SQL Server, and the rest ([SomeName1.SomeName2.SomeClass.SomeMethod]
) is the fully qualified function name, including the namespace.
Incidentally, if you deploy from Visual Studio it handles a lot of this for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With