I have been trying to find the answer to this simple question - but so far couldn't figure it out.
Let say I have MyDb.sqlproj, with various sql content (sprocs, views, trigger, etc).
I have added a new UDF through Add-> New item -> SQL CLR C#, User Defined Function.
For example:
namespace MyNameSpace
{
public class MyClass
{
[SqlFunction(DataAccess = DataAccessKind.Read)]
//I use different attributes here, but it doesn't matter
public static int Method1()
{
return 0;
}
}
}
In MyDb.sqlproj Properties, SQLCLR tab MyDb is the name of assembly and default namespace
In my sql code I call the clr method using EXTERNAL NAME:
CREATE PROCEDURE ClrMethod1
RETURNS [int] WITH EXECUTE AS CALLER
AS EXTERNAL NAME [MyDb].[MyNamespace.MyClass].[Method1]
I seem to tried everything to get the last line to compile. It cannot resolve the reference and get:
SQL71501: Function: [name of my sql function] has an unresolved reference to Assembly [MyDb]
Please point me to the right way to get it working. What could I be missing?
I am using VS2010 SP1 and latest version of SSDT