Pre script running issue

Packages and compresses schema and contents of SQL Server databases

Moderators: JonathanWatts, Chris Auckland, David Atkinson, david connell, Anu Deshpande, Michelle Taylor, james.billings, Marianne

Pre script running issue

Postby Satish » Tue Dec 20, 2011 8:19 pm


we ran into a problem while using the Red-Gate SQL Packager
We built a package and tried running it on a server where the packager is supposed to create a new database. The problem occurred when the packager tried to install a .net assembly file(dll) into the newly created database.
It threw an error that said
“CREATE ASSEMBLY for assembly 'Delta.SQLCLR' failed because assembly 'Delta.SQLCLR' is not authorized for PERMISSION_SET = UNSAFE. The assembly is authorized when either of the following is true: the database owner (DBO) has UNSAFE ASSEMBLY permission and the database has the TRUSTWORTHY database property on; or the assembly is signed with a certificate or an asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission.”
This could be fixed by using the statement “SET TRUSTWORTHY ON” on the newly created db.
But when we made the above script a part of the preSQL script and ran the packager in command line, it did not seem to have executed the above script and came back with the same error.
Posts: 1
Joined: Tue Dec 20, 2011 2:02 pm

Postby james.billings » Wed Dec 21, 2011 10:01 pm

Thanks for your post.
The /presql is run before the database is created, so it won't have actually made the change you expect.

One option would be to create the DB as part of your Pre-script, for instance if I wanted to create a table first:

Code: Select all
USE master
USE packagerDB
rowdata VARCHAR(200)

Then, in your commandline, specify the DB you just created and the /makeupgrade switch as opposed to the /makedatabase switch.

Hopefully that should help get around the problem.
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.

Return to SQL Packager 6

Who is online

Users browsing this forum: No registered users and 0 guests