I've been using the SqlCompare API to compare a database to a null database, and thus generate a create script. So far, it creates all database objects perfectly.
One thing I can't get it to do is to recreate the database itself, as it was. In particular, I need to script the following:
- The default collation.
The database owner.
The TRUSTWORTHY option set to true.
I don't mean I want to manually set them, I want the toolkit to detect them.
The database owner part may be hard - you would have to create the database with some default owner, then create the owner user, then make it the owner.
Most of these issues arise because I have CLR procedures that have WITH PERMISSION_SET = EXTERNAL_ACCESS.
I have also been looking at the SQL Packager and it's API and I can't seem to find where it might do the database creating. Am I correct in assuming there is no output 'CREATE DATABASE' script, but it is done in code?
If you have any suggestions for scripting the database and it's options and properties it would be very much appreciated.