mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
39 lines
1022 B
Plaintext
39 lines
1022 B
Plaintext
<#@output extension=".sql"#>
|
|
<#@ template language="C#" hostspecific="True" #>
|
|
|
|
--Drop the functions if they already exist
|
|
DROP FUNCTION IF EXISTS REGEX.MATCH
|
|
GO
|
|
DROP FUNCTION IF EXISTS REGEX.SUBSTRING
|
|
GO
|
|
DROP FUNCTION IF EXISTS REGEX.REPLACE
|
|
GO
|
|
|
|
DROP SCHEMA IF EXISTS REGEX;
|
|
GO
|
|
|
|
--Drop the assembly if it already exists
|
|
DROP ASSEMBLY IF EXISTS SqlClrRegEx
|
|
GO
|
|
|
|
--Create the assembly
|
|
CREATE ASSEMBLY SqlClrRegEx FROM '<#= this.Host.ResolvePath("bin\\Release\\SqlClrRegEx.dll") #>' WITH PERMISSION_SET = SAFE
|
|
GO
|
|
|
|
CREATE SCHEMA REGEX;
|
|
GO
|
|
|
|
--Create the functions
|
|
CREATE FUNCTION REGEX.MATCH (@src NVARCHAR(MAX), @regex NVARCHAR(4000))
|
|
RETURNS BIT
|
|
AS EXTERNAL NAME SqlClrRegEx.RegEx.CompiledMatch
|
|
GO
|
|
CREATE FUNCTION REGEX.SUBSTRING (@src NVARCHAR(MAX), @regex NVARCHAR(4000))
|
|
RETURNS NVARCHAR(4000)
|
|
AS EXTERNAL NAME SqlClrRegEx.RegEx.CompiledSubstring
|
|
GO
|
|
CREATE FUNCTION REGEX.REPLACE (@src NVARCHAR(MAX), @regex NVARCHAR(MAX), @value NVARCHAR(4000))
|
|
RETURNS NVARCHAR(MAX)
|
|
AS EXTERNAL NAME SqlClrRegEx.RegEx.CompiledReplace
|
|
GO
|