Share via


Exercise 2: Creating and a new Table in SQL Azure and Populate with Data

Task 1 – Creating a Table

  1. If you closed SQL Server Management Studio, open it again from Start > All Programs > SQL Server 2008 R2 November CTP > SQL Server Management Studio.
  2. Connect to the Customers database using your SQL Azure SQL Server login.
  3. Now you will add a table called StoreInformation to the Customers database. Execute the following query in a NewQuery window:

    T-SQL

    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 )

Task 2 – Populating the StoreInformation Table with Data

  1. Execute a series of queries similar to the following to add a set of rows to the new Customer table:

    T-SQL

    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')

  2. Now let’s query the data back out of the StoreInformation table to display the data you just entered.

    T-SQL

    SELECT * FROM Customers.dbo.StoreInformation

The result of the query should look something similar to the following:

Figure 7

Creating the StoreInformation Database