Updating the structure of multiple databases in Azure

Posted on

Question :

I have 5 SQL database ( Web Edition ) in Azure that should be exactly the same as the structure ( procedures , tabelas , views , triggers … ) but the data is different.

Can you update the bank structure in a more agile way, as if they were a mirror of a master bank?

    

Answer :

I have discovered something that solves my problems.
SQL Server Management Studio 2008 has a feature called Registered Databases.
After you register the databases with their credentials, you can run a script on all the banks at the same time.
To do this:

  • Open MSSMS and connect to any server, in my case it is the server called “LOCALDB”;
  • In the “Object Browser”, connect to other servers. “WEBDB” in my case;
  • Right-click on one of the servers and choose “Register”;
  • Set credentials and any name for the server and click Save;
  • Do the same with the other servers;
  • Now to run scripts all at once, just go to View > Registered Servers. Or press Ctrl + Alt + G.
    Expand the “Database Engine,” right-click “Local Server Groups” > “New Inquiry”.

    Notethatifthereismorethanoneserverinthe”Local Server Groups” the status bar of the script area will turn red indicating that the command will run on behalf of multiple logons.

    Thenamesofthebanksonbothserversshouldbethesame,andyoushouldusetheusecommand,thatis:

    usemeuBancodeDadosselect*fromminhaTB

    MyDatabasemustexistonthetwoserversoritwillonlyrunontheexistingone.

    Formoreinformation: link

        

    Yes, you can create a project database in Visual Studio, or use the SSDT (Sql Server Data Tools).

    link

    link

        

    Leave a Reply

    Your email address will not be published. Required fields are marked *