views:

229

answers:

1

Hello, I am trying to make my first CLR Assembly\stored procedure. I have compiled the code using CSC, and added the assembly to SQL server. The assembly shows up, but the class seems to be missing.

C# CODE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.SqlServer.Server;


namespace TextFunctions

public class RegularExpressions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static string RegExReplace(string input, string pattern, string replacement)
    {

        Regex Reginstance = new Regex(pattern);

        return Reginstance.Replace(input, replacement);


    }

}

END C# CODE

CREATE FUNCTION CODE

CREATE Function RegExReplace(@Input NVARCHAR(512),@Pattern NVARCHAR(127), @Replacement     NVARCHAR(512))
RETURNS NVARCHAR(512) EXTERNAL NAME RegEx.RegularExpressions.RegExReplace

ERROR Could not find Type 'RegularExpressions' in assembly 'RegEx'.

1) Can you see what I am doing rough?

2) Is there a table or view in sql server that lets me see the classes and functions inside an assembly?

+1  A: 

According to your code snippet your RegularExpressions class is in the TextFunctions namespace.

Changing your T-SQL code to use TextFunctions.RegularExpressions.RegExReplace should fix it.

Navaar
THANKS for the help! I did what you said, but it still did not work when I went into sql to create the function. I then deleted the Namespace portion (it is not necessary), and re-complied the dll. all is good now.
So please post a new answer and mark question as answered.
Shimmy