我正在尝试制作我的第一个CLR Assembly \存储过程。我使用CSC编译了代码,并将程序集添加到SQL服务器。程序集出现了,但是这个类似乎缺失了。
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);
}
}
结束C#代码
创建功能代码
CREATE Function RegExReplace(@Input NVARCHAR(512),@Pattern NVARCHAR(127), @Replacement NVARCHAR(512))
RETURNS NVARCHAR(512) EXTERNAL NAME RegEx.RegularExpressions.RegExReplace
ERROR 在程序集“RegEx”中找不到类型'RegularExpressions'。
1)你能看到我在做什么吗?
2)sql server中是否有表或视图可以让我看到程序集中的类和函数?
答案 0 :(得分:1)
根据您的代码段,您的RegularExpressions
类位于TextFunctions
命名空间中。
更改您的T-SQL代码以使用TextFunctions.RegularExpressions.RegExReplace应该修复它。