Exercise 2: Creating and a new Table in SQL Azure and Populate with Data
Task 1 – Creating a Table
- If you closed SQL Server Management Studio, open it again from Start > All Programs > SQL Server 2008 R2 November CTP > SQL Server Management Studio.
- Connect to the Customers database using your SQL Azure SQL Server login.
Now you will add a table called StoreInformation to the Customers database. Execute the following query in a NewQuery window:
CREATE TABLE [StoreInformation]( [StoreID] [int] IDENTITY(1,1)NOT NULL PRIMARY KEY CLUSTERED, [Title] [nvarchar](8)NULL, [StoreName] [nvarchar](50)NOT NULL, [StoreAddress] [nvarchar](50)NOT NULL, [StorePhone] [nvarchar](50)NOT NULL, [Latitude] [nvarchar](50)NOT NULL, [Longitude] [nvarchar](50)NOT NULL, [Hours] [nvarchar](8)NOT NULL, [Timestamp] [timestamp] NOT NULL )
Execute a series of queries similar to the following to add a set of rows to the new Customer table:
INSERT INTO [StoreInformation] ([Title],[StoreName],[StoreAddress],[StorePhone],[Latitude],[Longitude],[Hours]) VALUES ('30','Canyon Sports','Terrance Mall, Denver, CO USA','320-555-0188','38.627499999','102.221','12')
Now let’s query the data back out of the StoreInformation table to display the data you just entered.
SELECT * FROM Customers.dbo.StoreInformation
The result of the query should look something similar to the following:
Figure 7
Creating the StoreInformation Database