Add "USE DatabaseName" to DDL scripts

We are using Source Control on a SQL 2014 database with SVN.
We have added the database objects to SVN successfully however none of the DDL scripts have a use database statement,

Does anyone know how to generate the DDL scripts with the 'use <database>" statement ?

There is a Comparison option, however this is only for deployment scripts generation
<AddDatabaseUseStatement>True</AddDatabaseUseStatement>

Thanks

Comments

  • James BJames B Posts: 1,124 Silver 4
    Hi,

    You shouldn't need the use dbname statement in the scripts that are source controlled. In fact adding this is more likely to cause problems (for example if your development DB is called workDb, you commit everything, and another user tries to "get latest" the changes into a db called testDb) - the scripts in the repository are never intended to be manually run; they are simply a representation of your database.

    I'd be curious as to the use-case you have where the database name setting would be helpful?
    Systems Software Engineer

    Redgate Software

Sign In or Register to comment.