次の定義を仮定します。
/// <summary>
/// Replaces each occurrence of sPattern in sInput with sReplace. This is done
/// with the CLR:
/// new RegEx(sPattern, RegexOptions.Multiline).Replace(sInput, sReplace).
/// The result of the replacement is the return value.
/// </summary>
[SqlFunction(IsDeterministic = true)]
public static SqlString FRegexReplace(string sInput, string sPattern,
string sReplace)
{
return new Regex(sPattern, RegexOptions.Multiline).Replace(sInput, sReplace);
}
nvarchar(max)
長さが 4000 を超える値を渡すとsInput
、値が切り捨てられます (つまり、この UDF を呼び出した結果はnvarchar(4000)
、nvarchar(max)
.