charindex
のインデックスを検索するために使用できます。http://
次に、URLの末尾を検索する必要があります(データ、スペース、または "によって異なります)。
正規表現の検索を実装して、CLRスカラー関数を作成することもできます
using System;
using System.Collections;
using System.Text.RegularExpressions;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public class CLR
{
[SqlFunction(FillRowMethodName = "FillRow")]
public static IEnumerable RegexMatch(string pattern, string text)
{
var r = new Regex(pattern);
return r.Matches(text);
}
public static void FillRow(Object obj, out SqlInt32 index, out SqlString match)
{
var m = (Match)obj;
index = new SqlInt32(m.Groups[0].Index + 1);
match = new SqlString(m.Groups[0].Value);
}
}
次に、このクラスライブラリからSQLServer上にアセンブリを作成する必要があります
create assembly CLR from 'C:\CLR.dll' with permission_set = safe
次に、関数を作成できます
create function RegexMatch(@pattern nvarchar(4000), @text nvarchar(4000))
returns table ([index] int, match nvarchar(4000))
as external name CLR.CLR.RegexMatch