Databases Reference
In-Depth Information
with SQL Azure effectively. SQL Server 2012 and SQL Server 2008 R2 come with the ability to script an on-premises
database for the SQL Azure environment.
One of the differences between SQL Server 2012/2008 R2 and SQL Server 2008 (pertaining to object scripting) is
a setting in the Advanced Scripting Options dialog of the wizard. There are two properties you can set for the version
of SQL Server for which you're scripting database objects: Script for Server Version and Script for the Database Engine
Type. The Script for Server Version option lists the version of SQL Server that the Generate and Publish Scripts Wizard
supports, which ranges from SQL Server 2000 to SQL Server 2012.
The Script for the Database Engine Type property has two options you can choose from: Stand-Alone Instance
and SQL Azure Database. The SQL Azure Database option only works with the SQL Server 2012 and 2008 R2 Server
versions. For example, if you set the Script for Server version to SQL Server 2008 (non R2) and then set the Script for
the Database Engine Type property to SQL Azure Database, the Script for Server version property value automatically
changes to SQL Server 2012/2008 R2.
The Generate and Publish Scripts Wizard does a really nice job of appropriately scripting objects for SQL Azure.
The wizard checks for unsupported syntax and data types, and it checks for primary keys on each table. Thus, the
following example will set SQL for Server Version to SQL Server 2008 (non R2) for several reasons. First, many people
aren't using SQL Server 2012/2008 R2 and therefore don't have the option to script for SQL Azure. Second, this
exercise shows you what steps are needed to get a script ready to run in SQL Azure.
The database that will be used in this section is the trusty AdventureWorks database you can get from CodePlex:
http://msftdbprodsamples.codeplex.com/releases/view/55330
This database download is an .mdf specifically for SQL Server 2012. We will be using SQL Server Management
Studio for SQL Server 2012 to do our work, so fire it up and attach the download database.
Starting the Wizard
To start the Generate and Publish Scripts Wizard in SQL Server Management Studio (SSMS), open Object Explorer
and expand the Databases node. Select the AdventureWorks2012 database, right-click it, and then select Generate
Scripts from the context menu.
On the wizard's Introduction page for SQL Server 2012, you're informed that you must follow four steps to
complete this wizard:
1.
Select database objects.
2.
Specify scripting or publishing objects.
3.
Review selections.
4.
Generate scripts.
The following sections work through these steps.
Choosing Target Objects
To select your target database objects, follow these steps:
1.
On the Introduction page of the Generate and Publish Scripts Wizard, click Next.
2.
On the Choose Objects page (see Figure 4-15 ), select the Select Specific Database Objects
option, because for the purposes of this example, you simply want to select a few objects to
migrate.
 
Search WWH ::




Custom Search