人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

T-SQL中使用正則表達(dá)式函數(shù)

發(fā)布日期:2022-01-28 19:09 | 文章來源:gibhub

復(fù)制代碼 代碼如下:

/// <summary>
/// Regs the ex match.
/// </summary>
/// <param name="inputValue">The input value.</param>
/// <param name="regexPattern">The regex pattern.</param>
/// <remarks>Author: Petter Liu http://wintersun.cnblogs.com </remarks>
/// <returns>1 match,0 not match</returns>
[SqlFunction]
public static bool RegExMatch(string inputValue, string regexPattern)
{
// Any nulls - we can't match, return false
if (string.IsNullOrEmpty(inputValue) || string.IsNullOrEmpty(regexPattern))
return false; Regex r1 = new Regex(regexPattern.TrimEnd(null));
return r1.Match(inputValue.TrimEnd(null)).Success;
}

好了,Build后Deploy到你的Target database就OK了,VisualStudio會(huì)自動(dòng)注冊(cè)這個(gè)程序集的。如果,你想手動(dòng)注冊(cè)程序集,可執(zhí)行以下的T-SQL:
復(fù)制代碼 代碼如下:

CREATE ASSEMBLY [RegExCLR] FROM 'RegExCLR.dll'; -- Add the REGEX function. We want a friendly name
-- RegExMatch rather than the full namespace name.
-- Note the way we have to specify the Assembly.Namespace.Class.Function
-- NOTE the RegExCLR.RegExCLR
-- (one is the assembly the other is the namespace)
CREATE FUNCTION RegExMatch ( @inputCalue NVARCHAR(4000),
@regexPattern NVARCHAR(4000) ) RETURNS BIT
AS EXTERNAL NAME RegExCLR.RegExCLR.ClrClass.RegExMatch;

OK, 一切OK的后,我們來測(cè)試下: select COUNT(1) from Threads where dbo.RegExMatch(ThreadId,'^[{|\(]?[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}[\)|}]?$')=1
上面的T-SQL是找出Threads表ThreadId是GUID的記錄數(shù)。 等于1是匹配,^[{|\(]?[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}[\)|}]?$ 匹配GUID的正則表達(dá)式。 完了,希望這篇POST對(duì)您有幫助。 您可能對(duì)以下POST感興趣: SQLSERVER2008中CTE的Split與CLR的性能比較 SQLSERVER使用CLR Stored Procedure導(dǎo)出數(shù)據(jù)到Excel

美國(guó)服務(wù)器租用

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對(duì)1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部