-
Notifications
You must be signed in to change notification settings - Fork 35
/
load-assembly.sql
47 lines (36 loc) · 971 Bytes
/
load-assembly.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-- First, drop the functions if they already exist.
if OBJECT_ID('dbo.RegexMatch') is not null
begin
exec ('drop function dbo.RegexMatch');
end
go
if OBJECT_ID('dbo.RegexGroupMatch') is not null
begin
exec ('drop function dbo.RegexGroupMatch');
end
go
if OBJECT_ID('dbo.RegexReplace') is not null
begin
exec ('drop function dbo.RegexReplace');
end
go
if OBJECT_ID('dbo.RegexMatches') is not null
begin
exec ('drop function dbo.RegexMatches');
end
go
if OBJECT_ID('dbo.RegexSplit') is not null
begin
exec ('drop function dbo.RegexSplit');
end
go
-- Second, drop the assembly if it already exists
drop assembly RegexAssembly
go
-- Third, finally, create the assembly
declare @AssemblyLocation varchar(8000);
set @AssemblyLocation = '--SET LOCATION HERE, e.g. C:\Install\sql-server-regex-2016.dll'
CREATE ASSEMBLY RegexAssembly
FROM @AssemblyLocation
WITH PERMISSION_SET = SAFE;
-- see https://msdn.microsoft.com/en-us/library/ms189524.aspx for details