i want to create a CLR function, i created a normal class library file and coded as below, i dont want to use SqlServerProject, as i cannot find some classes there.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Types;
namespace ClassLibrary1
{
public partial class Class1
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString GetPassword(SqlString Value)
{
return Value;
}
}
}
i compiled the code and created assembly from sqlserver like this
CREATE ASSEMBLY ASSEM
authorization dbo
FROM 'E:\NBM Sites\tvt.stage.asentechdev1.com\ClassLibrary1.dll' WITH PERMISSION_SET = SAFE;
and created a function as below
CREATE FUNCTION SampleFunc
(
@value nvarchar(max)
)
RETURNS nvarchar(max) with execute as caller
AS
External Name ASSEM.Class1.GetPassword
GO
but the above create function threw an error saying.
Could not find Type 'Class1' in assembly 'ClassLibrary1'.
i dont understand, why the class1 is not recognised, as also i have made it public. Please any one help me for it.