EXEC sp_configure 'clr enabled', 1 RECONFIGURE WITH OVERRIDE GO ----建立建立包含類元數據和託管代碼的託管應用程序模塊,將其做爲 SQL Server 實例中的對象。 CREATE ASSEMBLY [Goophee.SQLTools] FROM 'F:\Work\微橋商城\Spider\WQSpider\SQLCLR\bin\Release\SQLCLR.dll' GO CREATE AGGREGATE JoinString (@input nvarchar(200),@seperator nvarchar(1)) RETURNS nvarchar(max) EXTERNAL NAME [Goophee.SQLTools].[SQLCLR.JoinString] Go CREATE FUNCTION dbo.RegLike ( @input nvarchar(max ), @pattern nvarchar(4000) ) RETURNS bit AS EXTERNAL NAME [Goophee.SQLTools].[SQLCLR.RegExp].RegExp_Like go CREATE FUNCTION dbo.RegReplace ( @input nvarchar(max ), @pattern nvarchar(4000), @replacement nvarchar(4000) ) RETURNS nvarchar(max ) AS EXTERNAL NAME [Goophee.SQLTools].[SQLCLR.RegExp].RegExp_Replace go drop AGGREGATE JoinString drop FUNCTION RegLike drop FUNCTION RegReplace drop ASSEMBLY [Goophee.SQLTools] ;with cte as ( select top 10 id from blog ) select dbo.JoinString(id,',') from cte select top 1 id from blog select dbo.RegReplace(contents,'<[^>]*>','') from blog where id='DEF61B29-4817-43B3-9393-00000E0CADF2'