Sql Server CLR Functions

When writing a Sql Server CLR function, can we use namespaces?

namespace SomeName1.SomeName2 { public static class SomeClass { [SqlFunction] public static SqlString SomeMethod(SqlString input) { // .... } } } 

If so, what will we call this function from SqlServer. In other words, what do we call CLR functions from SQL Server with namespaces?

+7
source share
1 answer

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 named in SQL Server, and the rest ( [SomeName1.SomeName2.SomeClass.SomeMethod] ) is the fully qualified name of the function, including the namespace.

By the way, if you deploy from Visual Studio, it handles a lot of all this for you.

+7
source

All Articles