How to Migrate Schema to SQL Azure Using the Generate SQL Server Scripts Wizard

There are many methods you can use to migrate data from an on-premise SQL Server database to SQL Azure.  Many of the methods only support migrating data, not schemas.  To migrate schemas, you can use the SQL Server Management Studio 2008 R2 Generate SQL Server Scripts Wizard.

To generate the schema

  1. Open SQL Server Management Studio 2008 R2 (SSMS).
  2. Connect to your SQL Server that contains the source database that you want to transfer.
  3. In Object Explorer, expand Databases.
  4. Right-click the database that you want to transfer, point to Tasks, and then click Generate Scripts.
  5. From Introduction, click Next.
  6. From Choose Objects, select the database objects that you want to migrate to SQL Azure, and then click Next.
  7. From Set Scripting Options, select Save to new query window, and then click Advanced.
  8. From Advanced Scripting Options, scroll down until you find Script for the database engine type, select SQl Azure Database, and then click OK.
  9. From Set Scripting Options, click Next.
  10. From Summary, click Next.
  11. Click Finish. The query appears in the query window. Don't close the window.  You will continue in the next procedure

To migrate the schema

  1. Right-click in the query window, point to Connection, and then click Change Connection.
  2. From Connect to Database Engine, enter Server name, and your credential, and then click Options.
  3. In Connect to database, type the database name where you want to transfer the schema to, and then click Connect.
  4. From SQL Editor menu, click Execute.  Monitor the Messages pane, and make sure all the commands complete successfully.

See Also

  • [[Overview of Options for Migrating Data and Schema to SQL Azure]]
  • [[How to use Data-Tier Application Import and Export with SQL Azure]]
  • [[SQL Azure Data Migration Using SQL Server Import and Export Wizard]]