question

mertel avatar image
mertel asked

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
backupbackup-restorebackupsclr
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
JohnM avatar image
JohnM answered
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!
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.