"USE" clause in creation statements

ergofaceergoface Posts: 6 Bronze 1
I know there is an option in SQL Compare to include 'USE <database>' statements when generating code. I have tried selecting this in the comparison options, but when the various table, view, stored procedure, code is generated in SQL Source control I can't get it to generate USE statement at the top.

I really need this both for our local coding standards and because if I have to run any of these generated scripts separately I will have to add it to ensure it runs properly.

I know that if I create a deployment using SQL Compare it will (with the option selected) add a USE statement at the top of the deployment script, but I need it in the individual creation scripts that are getting committed to source control.

I've looked, but don't see any other options that address this.

Dave Bennett
Dave Bennett


  • Hello Dave,

    Thanks for your question on SQL Source Control and comparison options. We do have the same option available. If you click a DB that is source controlled, go to the setup tab, scroll down to the section "Options just for this database", the click on "Comparison options". The one you're looking for should be at the top.
    Allen LeVan
    Red Gate Software
    US Product Support
  • I guess I wasn't clear enough. I did exactly what you said. I checked that option and it made no difference in the code that was generated, no USE statement.
    Looking at the option I had thought it would work the way you suggest, but it didn't.

    If you can show that it does work, what might I be doing wrong that it won't generate properly?

    Dave Bennett
Sign In or Register to comment.