一下依据要依据依据执行,不能批量执行,会报错
--DROP ASSEMBLY Regex --卸载
CREATE ASSEMBLY Regex from 'MSSQLRegexExtend.dll物理路径' WITH PERMISSION_SET = SAFE --注册.net类库
sp_configure 'clr enabled', 1 --将数据库设置为可以使用clr组件
RECONFIGURE --设置可用clr组件。别忘记运行这行进行应用
/****以下代码将类库中的静态方法注册为函数****/
/****正则匹配****/
--DROP FUNCTION [dbo].[Regex.Match]
CREATE FUNCTION [dbo].[Regex.Match](@Regex [nvarchar](max),@Input [nvarchar](max))
RETURNS [nvarchar](max) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [Regex].[MSSQLRegexExtend.RegexExtend].[Match]
/****正则替换****/
--DROP FUNCTION [dbo].[Regex.Replace]
CREATE FUNCTION [dbo].[Regex.Replace](@Regex [nvarchar](max),@Input [nvarchar](max),@Replace [nvarchar](max))
RETURNS [nvarchar](max) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [Regex].[MSSQLRegexExtend.RegexExtend].[Replace]
/****正则校验****/
--DROP FUNCTION [dbo].[Regex.IsMatch]
CREATE FUNCTION [dbo].[Regex.IsMatch](@Regex [nvarchar](max),@Input [nvarchar](max))
RETURNS [bit] WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [Regex].[MSSQLRegexExtend.RegexExtend].[IsMatch]
1