Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 porting a clr dll in C# from 2k5 to 2000

Author  Topic 

spinz2112
Starting Member

2 Posts

Posted - 2006-09-27 : 01:35:01
I wrote a class in C# with one method that returns a string. I built the dll and deployed the clr 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? If not using the existing dll, how would 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;

}



}

};


snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-09-27 : 09:38:02
To support regular expressions in SQL Server 2000 you can take a look here
http://www.sqlteam.com/item.asp?ItemID=13947

You could probably use that same technique and .NET COM interop to call .NET code in SQL Server 2000 but I haven't ever tried that and I don't really see the point unless you have some very custom .NET code (which yours isn't).
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-09-27 : 09:44:10
Quick follow-up regarding using SP_OA stored procedures and COM interop in SQL Server 2000

http://support.microsoft.com/?kbid=322884
http://www.mcse.ms/archive94-2004-12-1315650.html
Go to Top of Page

spinz2112
Starting Member

2 Posts

Posted - 2006-09-27 : 11:35:53
ive been cracking my head trying to make sense out of the above. im having difficulty figuring out how to just output the result, which should be the regex match on the input string like i have done in my code. can anyone help me to achieve this please? vbscript is not my expertise.
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-09-27 : 14:08:52
Here's an example that will do a little more than you need but should be simple enough to adapt
http://www.hillisgroup.com//snips/sql/folder.2006-04-18.7233561116/document.2006-04-20.6413635136
Go to Top of Page
   

- Advertisement -