Sunday, March 11, 2012

dll in c# sql 2005

I wrote a class in C# with one method that returns a string. I built the dll and deployed it into sql 2005 and everything works just fine.

I am now in a situation where I need to use this function in SQL 2000. Is there any way that I can use the existing dll and create a sql 2000 function, and if so how do I go about doing this?

Here is the c# code from the deployed dll.

using System;

using System.Data;

using System.Data.SqlClient;

using System.Data.SqlTypes;

using Microsoft.SqlServer.Server;

using System.Text.RegularExpressions;

public partial class GECBI

{

[Microsoft.SqlServer.Server.SqlFunction(IsDeterministic = true, IsPrecise = true)]

public static string RegExMatch(string pattern, string matchString)

{

Regex r1 = new Regex(pattern);

if (r1.Match(matchString.TrimEnd(null)).Success)

{

Regex testReg = new Regex(pattern);

Match regMatch = testReg.Match(matchString);

string runnumber = regMatch.ToString();

return runnumber;

}

else

{

return null;

}

}

};

Accesing CLR Function is only possible in SQL2k5. Wrapping the .NET object in a COM object or calling the function on a SQL2k5 Server would be very slow during execution time.

HTH, JEns K. Suessmeyer.

http://www.sqlserver2005.de|||So what would be an alternative for me to achieve the above? Can someone give me an example of how to create the above function in something that I can use with sql 2k please?|||There is actually no alternativ for that. have a look in the internet, there have been some samples implemented to mimic the functionality.

http://www.google.de/search?hl=de&q=regular+expressions+sql+server+2000&meta= http://www.codeproject.com/managedcpp/xpregex.asp

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

No comments:

Post a Comment