x

CLR-Integration and DB Backups

I have a CLR-integrated Scalar value function (from C# DLL). My configuration script is similar to:

 sp_configure 'clr enabled', 1
 reconfigure
 go
 create assembly [MyProject] from 'C:\Program Files\...\MyProject.dll' with permission_set = UNSAFE
 go
 create function [dbo].[MyScalar] ( @string VARCHAR(50))
 returns VARCHAR(50)
 AS
 external name [MyProject].[UserDefinedFunctions].[MyScalar]
 go

Now, the Question: If I backup my database, then restore, is my CLR-integrated MyFunction() readily available (without re-running my CLR script)? Does the original DLL still need to be available to Database? Is MyFunction captured in the database backup? Thanks,Mike

more ▼

asked Mar 09, 2016 at 06:30 PM in Default

avatar image

mertel
10 4

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

It should be, yes. The CREATE ASSEMBLY function will essentially import the DLL into the database itself. You should be able to restore the database to any appropriate server and have the function available.

You should be able to verify by restoring it and looking in the [databasename].sys.assemblies.

FYI - you might have permission issues on the function on the new server. It's discussed here: http://sqlblog.com/blogs/jonathan_kehayias/archive/2008/03/06/clr-safety-issues-after-database-restore-to-new-server.aspx. Don't know if it'll apply but just in case you run into it this can be a starting point for you.

Hope that helps!

more ▼

answered Mar 09, 2016 at 09:39 PM

avatar image

JohnM
14.2k 3 7 14

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x247
x65
x34
x31

asked: Mar 09, 2016 at 06:30 PM

Seen: 147 times

Last Updated: Mar 09, 2016 at 09:50 PM

Copyright 2017 Redgate Software. Privacy Policy