Skip to content

Commit 18f723d

Browse files
committed
Deployment fixes
1 parent 88566a4 commit 18f723d

File tree

5 files changed

+107
-26
lines changed

5 files changed

+107
-26
lines changed

sql_clr_ics/Script.PreDeployment.sql

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,50 @@
99
SELECT * FROM [$(TableName)]
1010
--------------------------------------------------------------------------------------
1111
*/
12+
-- Make sure clr is enabled
13+
DECLARE @InitAdvanced INT
14+
15+
IF EXISTS (select * from sys.configurations where name IN ('clr enabled') and value_in_use = 0)
16+
BEGIN
17+
SELECT @InitAdvanced = CONVERT(int, value) FROM sys.configurations WHERE name = 'show advanced options';
18+
19+
IF @InitAdvanced = 0
20+
BEGIN
21+
EXEC sp_configure 'show advanced options', 1;
22+
RECONFIGURE;
23+
END
24+
25+
IF EXISTS (select * from sys.configurations where name = 'clr enabled' and value_in_use = 0)
26+
BEGIN
27+
EXEC sp_configure 'clr enabled', 1;
28+
RECONFIGURE;
29+
END
30+
31+
IF @InitAdvanced = 0
32+
BEGIN
33+
EXEC sp_configure 'show advanced options', 0;
34+
RECONFIGURE;
35+
END
36+
END
37+
GO
1238
use [master];
1339
GO
14-
IF NOT EXISTS (select * from sys.asymmetric_keys WHERE name = 'sql_clr_ics_pkey')
40+
-- Create symmetric key from DLL
41+
IF NOT EXISTS (
42+
select * from master.sys.asymmetric_keys
43+
WHERE
44+
name = 'sql_clr_ics_pkey'
45+
--thumbprint = 0xC5022B1D1415FC7A
46+
)
1547
create asymmetric key sql_clr_ics_pkey
1648
from executable file = '$(PathToSignedDLL)'
1749
--encryption by password = 'vtwjmifewVfnhrYke@ZuhxkumsFT7_&#$!~<avjqn|mnvJhp'
1850
GO
19-
IF NOT EXISTS (select name from sys.syslogins where name = 'sql_clr_ics_login')
51+
-- Create server login from symmetric key
52+
IF NOT EXISTS (select name from master.sys.syslogins where name = 'sql_clr_ics_login')
2053
create login sql_clr_ics_login from asymmetric key sql_clr_ics_pkey;
2154
GO
55+
-- Grant UNSAFE ASSEMBLY permissions to login which was created from DLL signing key
2256
grant unsafe assembly to sql_clr_ics_login;
2357
GO
2458
-- Return execution context to intended target database

sql_clr_ics/sql_clr_ics.publish.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212
<ItemGroup>
1313
<SqlCmdVariable Include="PathToSignedDLL">
14-
<Value>C:\ClrIcsTest\sql_clr_ics.dll</Value>
14+
<Value>C:\SqlClrIcs\sql_clr_ics.dll</Value>
1515
</SqlCmdVariable>
1616
</ItemGroup>
1717
</Project>

sql_clr_ics/sql_clr_ics.sqlproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
</ItemGroup>
9898
<ItemGroup>
9999
<SqlCmdVariable Include="PathToSignedDLL">
100-
<DefaultValue>C:\ClrIcsTest\sql_clr_ics.dll</DefaultValue>
100+
<DefaultValue>C:\SqlClrIcs\sql_clr_ics.dll</DefaultValue>
101101
<Value>$(SqlCmdVar__1)</Value>
102102
</SqlCmdVariable>
103103
</ItemGroup>

sql_clr_ics/sql_clr_ics_install.sql

Lines changed: 69 additions & 22 deletions
Large diffs are not rendered by default.

sql_clr_ics/sql_clr_ics_pkey.pfx

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)