813
Chapter 31: Managing Data in Windows Azure SQL Database
31
- Click Finish. At this point your script is fi nished and displays in a query window
in SSMS.
Reviewing the Generated Script
The following snippet is a create table statement from the results of the Generate Script
wizard. 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: Table [dbo].[Contact] Script Date: 04/07/2012 10:31:32******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Contact](
[ContactID] [int] IDENTITY(1,1) NOT FOR REPLICATION 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,
[EmailAddress] [nvarchar](50) NULL,
[EmailPromotion] [int] NOT NULL,
[Phone] [nvarchar](25) NULL,
[PasswordHash] [varchar](128) NOT NULL,
[PasswordSalt] [varchar](10) NOT NULL,
[rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[ModifiedDate] [datetime] NOT NULL,
CONSTRAINT [PK_Contact_ContactID] PRIMARY KEY CLUSTERED
(
[ContactID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
The script fi rst enables several options, such as ANSI_NULL and ANSI_PADDING. Then, the
script creates the Contact table. This table has an identity column that applies the
not for replication clause, which means that this column cannot be used in SQL
Server Replication. The Contact table also has a rowguid column that uses the
uniqueidentifier data type. Also notice in the resulting script that the rowguid
column also has a default on it, which uses the newsequentialid() function to automat-
ically generate new GUIDs. Lastly, this table is created on the primary fi le group, followed
by the setting of several table options via the with clause.
Further down in the script, a stored procedure is created, uspGetManagerEmployees.
This stored procedure is a standard stored procedure that accepts single input parameters
c31.indd 813c31.indd 813 7/31/2012 10:00:26 AM7/31/2012 10:00:26 AM
http://www.it-ebooks.info