Databases Reference
In-Depth Information
You can also set the Script DROP and CREATE option to Script DROP and CREATE, as
shown in Figure 4-17 , but that option isn't required for SQL Azure.
2.
Click OK in the Advanced Scripting Options dialog, and then click Next in the Generate
Scripts wizard.
3.
On the wizard's Summary page, review your selections, and then click Next. The T-SQL
script is generated, and you're taken to the Save or Publish Scripts page.
4.
Click Finish. At this point your script is finished and is displayed in a query window
in SSMS.
Reviewing the Generated Script
Open the file you created, and let's take a quick look at the generated T-SQL. The following snippet from what you see
shows the creation of an XML Schema collection and a single table. To save space in the chapter, the majority of the
XML Schema Collection has been left out, along with creation of some of the constraints, but your script will show
the entire CREATE statement. Also, except for the things you told the script-generation wizard to ignore, the following
T-SQL looks like all other object creation T-SQL you typically deal with on a daily basis:
/****** Object: Schema [Person] Script Date: 4/22/2012 3:38:28 PM ******/
CREATE SCHEMA [Person]
GO
/****** Object: XmlSchemaCollection [Person].[IndividualSurveySchemaCollection] Script Date:
4/22/2012 3:38:28 PM ******/
CREATE XML SCHEMA COLLECTION [Person].[IndividualSurveySchemaCollection]
AS N'<xsd:schema xmlns:xsd=" http://www.w3.org/2001/XMLSchema "
...
</xsd:schema>'
GO
/****** Object: UserDefinedDataType [dbo].[Name] Script Date: 4/22/2012 3:38:28 PM ******/
CREATE TYPE [dbo].[Name] FROM [nvarchar](50) NULL
GO
/****** Object: UserDefinedDataType [dbo].[NameStyle] Script Date: 4/22/2012 3:38:28 PM ******/
CREATE TYPE [dbo].[NameStyle] FROM [bit] NOT NULL
GO
/****** Object: Table [Person].[Person] Script Date: 4/22/2012 3:38:28 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Person].[Person](
[BusinessEntityID] [int] NOT NULL,
[PersonType] [nchar](2) NOT NULL,
[NameStyle] [bit] NOT NULL,
[Title] [nvarchar](8) NULL,
[FirstName] [nvarchar](50) NOT NULL,
[MiddleName] [nvarchar](50) NULL,
[LastName] [nvarchar](50) NOT NULL,
[Suffix] [nvarchar](10) NULL,
[EmailPromotion] [int] NOT NULL,
[AdditionalContactInfo] [xml](CONTENT [Person].[AdditionalContactInfoSchemaCollection]) NULL,
 
Search WWH ::




Custom Search