Ecco a voi (compilare come assembly SQL CLR):
using System.Collections;
using System.Text.RegularExpressions;
using Microsoft.SqlServer.Server;
public partial class UserDefinedFunctions
{
[SqlFunction]
public static bool RegexMatch(string expr, string regex)
{
return Regex.IsMatch(expr, regex);
}
[SqlFunction]
public static string RegexReplace(string expr, string regex, string replace)
{
return Regex.Replace(expr, regex, replace);
}
[SqlFunction(FillRowMethodName="GetToken",
TableDefinition="Value nvarchar(max)")]
public static IEnumerable RegexSplit(string expr, string regex)
{
return Regex.Split(expr, regex);
}
public static void GetToken(object row, out string str)
{
str = (string) row;
}
}