What are the challenges you face when working across database platforms? Take the survey
Options

Create database on Azure SQL

Hi,

We are investigating options to move our solutions into MS Azure. When using Azure SQL, it is apparently not possible to use the "USE" statement within a script. Does SQL Change Automation have some way of taking care of this issue or do we need to modify all current scripts that have the "USE" statement in them? I have tried setting the project's target platform to MS Azure SQL Database, but that does not seem to help.

Thank you for any help provided.
Tagged:

Answers

  • Options
    SQL Change Automation scripts do not require an USE statement, since it will be created at deployment based on the settings you choose.

    If your existing scripts have USE statements, then you should remove them.
    Sergio
    Product Support Engineer
    Redgate Software Ltd
    Please see our Help Center for detailed guides on how to use our tools
  • Options
    TOpelTOpel Posts: 2 New member
    Hi, thank you for the response.

    I don't know what I am doing wrong, but I am unable to deploy even a simple project to the Azure SQL. Here is a GitLab repository of the project I have tried. If I use the button to "Create database" I get the following error:

    Azure SQL Database does not support switching between databases. Connect to [{dbname}] and then re-run the script.

    I tried creating the database manually and then connecting to it, at which point the communication was successful and the DB was updated. Do I always need to create the DB manually first and then connecting to it directly in order to make SQL Change Automation work?
  • Options
    Yes, you should pre-create any development targets in SQL Change Automation.
    You can use the Pre-Deployment script for this if needed.
    Sergio
    Product Support Engineer
    Redgate Software Ltd
    Please see our Help Center for detailed guides on how to use our tools
Sign In or Register to comment.