Support for Screencast under development
  This blog post is providing snippets for a screencast under development. It will grow in size and will include video downloads, with full source.

 
Beginning Source Code Snippets
  Snippet – Create database
 
hyperlink2  

View and download create database script


USE [master]
GO
/****** Object:  Database [MarketIndexData]    Script Date: 11/24/2010 13:37:40 ******/
CREATE DATABASE [MarketIndexData] ON  PRIMARY 
( NAME = N'MarketIndexData', FILENAME = N'C:\databases\MarketIndexData.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'MarketIndexData_log', FILENAME = N'C:\databases\MarketIndexData_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [MarketIndexData] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [MarketIndexData].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [MarketIndexData] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [MarketIndexData] SET ANSI_NULLS OFF
GO
ALTER DATABASE [MarketIndexData] SET ANSI_PADDING OFF
GO
ALTER DATABASE [MarketIndexData] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [MarketIndexData] SET ARITHABORT OFF
GO
ALTER DATABASE [MarketIndexData] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [MarketIndexData] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [MarketIndexData] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [MarketIndexData] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [MarketIndexData] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [MarketIndexData] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [MarketIndexData] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [MarketIndexData] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [MarketIndexData] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [MarketIndexData] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [MarketIndexData] SET  DISABLE_BROKER
GO
ALTER DATABASE [MarketIndexData] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [MarketIndexData] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [MarketIndexData] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [MarketIndexData] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [MarketIndexData] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [MarketIndexData] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [MarketIndexData] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [MarketIndexData] SET  READ_WRITE
GO
ALTER DATABASE [MarketIndexData] SET RECOVERY FULL
GO
ALTER DATABASE [MarketIndexData] SET  MULTI_USER
GO
ALTER DATABASE [MarketIndexData] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [MarketIndexData] SET DB_CHAINING OFF
GO
EXEC sys.sp_db_vardecimal_storage_format N'MarketIndexData', N'ON'
GO
USE [MarketIndexData]
GO
/****** Object:  Table [dbo].[Assets]    Script Date: 11/24/2010 13:37:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Assets](
    [AssetID] [nchar](16) NOT NULL,
    [Description] [nvarchar](max) NOT NULL,
 CONSTRAINT [PK_Assets] PRIMARY KEY CLUSTERED 
(
    [AssetID] 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
INSERT [dbo].[Assets] ([AssetID], [Description]) VALUES (N'DJ              ', N'Dow Jones Industrials Index')
INSERT [dbo].[Assets] ([AssetID], [Description]) VALUES (N'EUROSTOXX       ', N'EuroZone Index')
INSERT [dbo].[Assets] ([AssetID], [Description]) VALUES (N'SP500           ', N'Standard & Poors 500 Stock Market Index')
/****** Object:  Table [dbo].[AssetPrices]    Script Date: 11/24/2010 13:37:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AssetPrices](
    [AssetPricesId] [int] IDENTITY(1,1) NOT NULL,
    [AssetID] [nchar](16) NULL,
    [DatePrice] [smalldatetime] NOT NULL,
    [OpenPrice] [real] NOT NULL,
 CONSTRAINT [PK_AssetPrices] PRIMARY KEY CLUSTERED 
(
    [AssetPricesId] 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
SET IDENTITY_INSERT [dbo].[AssetPrices] ON
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (1, N'SP500           ', CAST(0x9DB50000 AS SmallDateTime), 1077.23)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (2, N'SP500           ', CAST(0x9DAE0000 AS SmallDateTime), 1022.58)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (3, N'SP500           ', CAST(0x9DA70000 AS SmallDateTime), 1077.5)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (4, N'SP500           ', CAST(0x9DA00000 AS SmallDateTime), 1122.79)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (5, N'SP500           ', CAST(0x9D990000 AS SmallDateTime), 1095)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (6, N'SP500           ', CAST(0x9D920000 AS SmallDateTime), 1065.84)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (7, N'SP500           ', CAST(0x9D8B0000 AS SmallDateTime), 1089.41)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (8, N'SP500           ', CAST(0x9D840000 AS SmallDateTime), 1084.78)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (9, N'SP500           ', CAST(0x9D7D0000 AS SmallDateTime), 1136.52)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (10, N'SP500           ', CAST(0x9D760000 AS SmallDateTime), 1122.27)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (11, N'SP500           ', CAST(0x9D6F0000 AS SmallDateTime), 1188.57)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (12, N'SP500           ', CAST(0x9D680000 AS SmallDateTime), 1217.06)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (13, N'SP500           ', CAST(0x9D610000 AS SmallDateTime), 1192.06)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (14, N'SP500           ', CAST(0x9D5A0000 AS SmallDateTime), 1194.93)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (15, N'SP500           ', CAST(0x9D530000 AS SmallDateTime), 1178.71)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (16, N'SP500           ', CAST(0x9D4B0000 AS SmallDateTime), 1167.7)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (17, N'SP500           ', CAST(0x9D450000 AS SmallDateTime), 1157.25)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (18, N'SP500           ', CAST(0x9D3E0000 AS SmallDateTime), 1148.53)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (19, N'SP500           ', CAST(0x9D370000 AS SmallDateTime), 1138.4)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (20, N'SP500           ', CAST(0x9D300000 AS SmallDateTime), 1105.36)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (21, N'SP500           ', CAST(0x9D290000 AS SmallDateTime), 1110)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (22, N'SP500           ', CAST(0x9D220000 AS SmallDateTime), 1075.51)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (23, N'SP500           ', CAST(0x9D1B0000 AS SmallDateTime), 1065.51)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (24, N'SP500           ', CAST(0x9D140000 AS SmallDateTime), 1073.89)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (25, N'SP500           ', CAST(0x9D0D0000 AS SmallDateTime), 1092.4)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (26, N'SP500           ', CAST(0x9D060000 AS SmallDateTime), 1136.03)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (27, N'SP500           ', CAST(0x9CFF0000 AS SmallDateTime), 1145.96)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (28, N'SP500           ', CAST(0x9CF80000 AS SmallDateTime), 1116.56)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (29, N'SP500           ', CAST(0x9CF00000 AS SmallDateTime), 1127.5)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (30, N'SP500           ', CAST(0x9CE90000 AS SmallDateTime), 1105.31)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (31, N'SP500           ', CAST(0x9CE30000 AS SmallDateTime), 1107.84)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (32, N'SP500           ', CAST(0x9CDC0000 AS SmallDateTime), 1105.52)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (33, N'SP500           ', CAST(0x9CD50000 AS SmallDateTime), 1091.06)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (34, N'SP500           ', CAST(0x9CCE0000 AS SmallDateTime), 1094.86)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (35, N'SP500           ', CAST(0x9CC70000 AS SmallDateTime), 1094.13)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (36, N'SP500           ', CAST(0x9CC00000 AS SmallDateTime), 1072.31)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (37, N'SP500           ', CAST(0x9CB90000 AS SmallDateTime), 1036.18)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (38, N'SP500           ', CAST(0x9CB20000 AS SmallDateTime), 1080.36)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (39, N'SP500           ', CAST(0x9CAB0000 AS SmallDateTime), 1088.22)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (40, N'SP500           ', CAST(0x9CA40000 AS SmallDateTime), 1071.63)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (41, N'SP500           ', CAST(0x9C9D0000 AS SmallDateTime), 1026.87)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (42, N'SP500           ', CAST(0x9C960000 AS SmallDateTime), 1045.38)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (43, N'SP500           ', CAST(0x9C8F0000 AS SmallDateTime), 1067.14)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (44, N'SP500           ', CAST(0x9C880000 AS SmallDateTime), 1040.15)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (45, N'SP500           ', CAST(0x9C810000 AS SmallDateTime), 1018.67)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (46, N'SP500           ', CAST(0x9C7A0000 AS SmallDateTime), 1025.21)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (47, N'SP500           ', CAST(0x9C730000 AS SmallDateTime), 1026.59)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (48, N'SP500           ', CAST(0x9C6C0000 AS SmallDateTime), 998.18)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (49, N'SP500           ', CAST(0x9C650000 AS SmallDateTime), 1008.89)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (50, N'SP500           ', CAST(0x9C5E0000 AS SmallDateTime), 990.22)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (51, N'SP500           ', CAST(0x9C570000 AS SmallDateTime), 978.63)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (52, N'SP500           ', CAST(0x9C500000 AS SmallDateTime), 942.07)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (53, N'DJ              ', CAST(0x9DB50000 AS SmallDateTime), 10199.24)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (54, N'DJ              ', CAST(0x9DAE0000 AS SmallDateTime), 9686.48)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (55, N'DJ              ', CAST(0x9DA70000 AS SmallDateTime), 10143.05)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (56, N'DJ              ', CAST(0x9DA00000 AS SmallDateTime), 10452.46)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (57, N'DJ              ', CAST(0x9D990000 AS SmallDateTime), 10211.83)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (58, N'DJ              ', CAST(0x9D920000 AS SmallDateTime), 9931.75)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (59, N'DJ              ', CAST(0x9D8B0000 AS SmallDateTime), 10136.63)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (60, N'DJ              ', CAST(0x9D840000 AS SmallDateTime), 10193.46)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (61, N'DJ              ', CAST(0x9D7D0000 AS SmallDateTime), 10616.98)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (62, N'DJ              ', CAST(0x9D760000 AS SmallDateTime), 10386.18)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (63, N'DJ              ', CAST(0x9D6F0000 AS SmallDateTime), 11009.6)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (64, N'DJ              ', CAST(0x9D680000 AS SmallDateTime), 11205.11)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (65, N'DJ              ', CAST(0x9D610000 AS SmallDateTime), 11018.36)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (66, N'DJ              ', CAST(0x9D5A0000 AS SmallDateTime), 10996.75)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (67, N'DJ              ', CAST(0x9D530000 AS SmallDateTime), 10927.45)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (68, N'DJ              ', CAST(0x9D4B0000 AS SmallDateTime), 10849.23)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (69, N'DJ              ', CAST(0x9D450000 AS SmallDateTime), 10741)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (70, N'DJ              ', CAST(0x9D3E0000 AS SmallDateTime), 10623.41)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (71, N'DJ              ', CAST(0x9D370000 AS SmallDateTime), 10563.78)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (72, N'DJ              ', CAST(0x9D300000 AS SmallDateTime), 10326.1)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (73, N'DJ              ', CAST(0x9D290000 AS SmallDateTime), 10402.43)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (74, N'DJ              ', CAST(0x9D220000 AS SmallDateTime), 10099.14)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (75, N'DJ              ', CAST(0x9D1B0000 AS SmallDateTime), 10005.43)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (76, N'DJ              ', CAST(0x9D140000 AS SmallDateTime), 10068.99)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (77, N'DJ              ', CAST(0x9D0D0000 AS SmallDateTime), 10175.1)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (78, N'DJ              ', CAST(0x9D060000 AS SmallDateTime), 10609.65)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (79, N'DJ              ', CAST(0x9CFF0000 AS SmallDateTime), 10620.31)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (80, N'DJ              ', CAST(0x9CF80000 AS SmallDateTime), 10430.69)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (81, N'DJ              ', CAST(0x9CF00000 AS SmallDateTime), 10517.91)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (82, N'DJ              ', CAST(0x9CE90000 AS SmallDateTime), 10330.1)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (83, N'DJ              ', CAST(0x9CE30000 AS SmallDateTime), 10471.28)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (84, N'DJ              ', CAST(0x9CDC0000 AS SmallDateTime), 10386.86)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (85, N'DJ              ', CAST(0x9CD50000 AS SmallDateTime), 10309.77)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (86, N'DJ              ', CAST(0x9CCE0000 AS SmallDateTime), 10320.13)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (87, N'DJ              ', CAST(0x9CC70000 AS SmallDateTime), 10267.53)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (88, N'DJ              ', CAST(0x9CC00000 AS SmallDateTime), 10020.62)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (89, N'DJ              ', CAST(0x9CB90000 AS SmallDateTime), 9712.13)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (90, N'DJ              ', CAST(0x9CB20000 AS SmallDateTime), 9972.33)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (91, N'DJ              ', CAST(0x9CAB0000 AS SmallDateTime), 9996.67)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (92, N'DJ              ', CAST(0x9CA40000 AS SmallDateTime), 9865.24)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (93, N'DJ              ', CAST(0x9C9D0000 AS SmallDateTime), 9488.73)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (94, N'DJ              ', CAST(0x9C960000 AS SmallDateTime), 9663.23)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (95, N'DJ              ', CAST(0x9C8F0000 AS SmallDateTime), 9818.61)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (96, N'DJ              ', CAST(0x9C880000 AS SmallDateTime), 9598.08)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (97, N'DJ              ', CAST(0x9C810000 AS SmallDateTime), 9441.27)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (98, N'DJ              ', CAST(0x9C7A0000 AS SmallDateTime), 9542.91)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (99, N'DJ              ', CAST(0x9C730000 AS SmallDateTime), 9506.18)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (100, N'DJ              ', CAST(0x9C6C0000 AS SmallDateTime), 9313.85)
GO
print 'Processed 100 total records'
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (101, N'DJ              ', CAST(0x9C650000 AS SmallDateTime), 9368.41)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (102, N'DJ              ', CAST(0x9C5E0000 AS SmallDateTime), 9173.65)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (103, N'DJ              ', CAST(0x9C570000 AS SmallDateTime), 9093.09)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (104, N'DJ              ', CAST(0x9C500000 AS SmallDateTime), 8746.05)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (105, N'EUROSTOXX       ', CAST(0x9DB50000 AS SmallDateTime), 33.23)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (106, N'EUROSTOXX       ', CAST(0x9DAE0000 AS SmallDateTime), 30.87)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (107, N'EUROSTOXX       ', CAST(0x9DA70000 AS SmallDateTime), 32.16)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (108, N'EUROSTOXX       ', CAST(0x9DA00000 AS SmallDateTime), 33.87)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (109, N'EUROSTOXX       ', CAST(0x9D990000 AS SmallDateTime), 33)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (110, N'EUROSTOXX       ', CAST(0x9D920000 AS SmallDateTime), 30.72)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (111, N'EUROSTOXX       ', CAST(0x9D8B0000 AS SmallDateTime), 32.22)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (112, N'EUROSTOXX       ', CAST(0x9D840000 AS SmallDateTime), 31.77)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (113, N'EUROSTOXX       ', CAST(0x9D7D0000 AS SmallDateTime), 32.98)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (114, N'EUROSTOXX       ', CAST(0x9D760000 AS SmallDateTime), 35.08)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (115, N'EUROSTOXX       ', CAST(0x9D6F0000 AS SmallDateTime), 36.77)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (116, N'EUROSTOXX       ', CAST(0x9D680000 AS SmallDateTime), 38.56)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (117, N'EUROSTOXX       ', CAST(0x9D610000 AS SmallDateTime), 38.75)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (118, N'EUROSTOXX       ', CAST(0x9D5A0000 AS SmallDateTime), 40)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (119, N'EUROSTOXX       ', CAST(0x9D530000 AS SmallDateTime), 39.91)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (120, N'EUROSTOXX       ', CAST(0x9D4B0000 AS SmallDateTime), 38.89)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (121, N'EUROSTOXX       ', CAST(0x9D450000 AS SmallDateTime), 37.94)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (122, N'EUROSTOXX       ', CAST(0x9D3E0000 AS SmallDateTime), 38.88)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (123, N'EUROSTOXX       ', CAST(0x9D370000 AS SmallDateTime), 38.76)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (124, N'EUROSTOXX       ', CAST(0x9D300000 AS SmallDateTime), 36.77)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (125, N'EUROSTOXX       ', CAST(0x9D290000 AS SmallDateTime), 37.32)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (126, N'EUROSTOXX       ', CAST(0x9D220000 AS SmallDateTime), 36.04)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (127, N'EUROSTOXX       ', CAST(0x9D1B0000 AS SmallDateTime), 35.8)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (128, N'EUROSTOXX       ', CAST(0x9D140000 AS SmallDateTime), 38.21)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (129, N'EUROSTOXX       ', CAST(0x9D0D0000 AS SmallDateTime), 39.27)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (130, N'EUROSTOXX       ', CAST(0x9D060000 AS SmallDateTime), 41.63)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (131, N'EUROSTOXX       ', CAST(0x9CFF0000 AS SmallDateTime), 43.3)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (132, N'EUROSTOXX       ', CAST(0x9CF80000 AS SmallDateTime), 42.48)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (133, N'EUROSTOXX       ', CAST(0x9CF00000 AS SmallDateTime), 42.38)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (134, N'EUROSTOXX       ', CAST(0x9CE90000 AS SmallDateTime), 40.8)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (135, N'EUROSTOXX       ', CAST(0x9CE30000 AS SmallDateTime), 41.84)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (136, N'EUROSTOXX       ', CAST(0x9CDC0000 AS SmallDateTime), 42.29)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (137, N'EUROSTOXX       ', CAST(0x9CD50000 AS SmallDateTime), 41.63)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (138, N'EUROSTOXX       ', CAST(0x9CCE0000 AS SmallDateTime), 42.52)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (139, N'EUROSTOXX       ', CAST(0x9CC70000 AS SmallDateTime), 43.08)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (140, N'EUROSTOXX       ', CAST(0x9CC00000 AS SmallDateTime), 41.8)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (141, N'EUROSTOXX       ', CAST(0x9CB90000 AS SmallDateTime), 39.89)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (142, N'EUROSTOXX       ', CAST(0x9CB20000 AS SmallDateTime), 42.7)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (143, N'EUROSTOXX       ', CAST(0x9CAB0000 AS SmallDateTime), 43.1)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (144, N'EUROSTOXX       ', CAST(0x9CA40000 AS SmallDateTime), 42.37)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (145, N'EUROSTOXX       ', CAST(0x9C9D0000 AS SmallDateTime), 39.84)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (146, N'EUROSTOXX       ', CAST(0x9C960000 AS SmallDateTime), 41.25)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (147, N'EUROSTOXX       ', CAST(0x9C8F0000 AS SmallDateTime), 41.19)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (148, N'EUROSTOXX       ', CAST(0x9C880000 AS SmallDateTime), 40.37)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (149, N'EUROSTOXX       ', CAST(0x9C810000 AS SmallDateTime), 40.05)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (150, N'EUROSTOXX       ', CAST(0x9C7A0000 AS SmallDateTime), 39.21)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (151, N'EUROSTOXX       ', CAST(0x9C730000 AS SmallDateTime), 39.1)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (152, N'EUROSTOXX       ', CAST(0x9C6C0000 AS SmallDateTime), 36.37)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (153, N'EUROSTOXX       ', CAST(0x9C650000 AS SmallDateTime), 37.67)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (154, N'EUROSTOXX       ', CAST(0x9C5E0000 AS SmallDateTime), 37.64)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (155, N'EUROSTOXX       ', CAST(0x9C570000 AS SmallDateTime), 36.36)
INSERT [dbo].[AssetPrices] ([AssetPricesId], [AssetID], [DatePrice], [OpenPrice]) VALUES (156, N'EUROSTOXX       ', CAST(0x9C500000 AS SmallDateTime), 35.08)
SET IDENTITY_INSERT [dbo].[AssetPrices] OFF
/****** Object:  ForeignKey [FK_AssetPrices_Assets]    Script Date: 11/24/2010 13:37:42 ******/
ALTER TABLE [dbo].[AssetPrices]  WITH NOCHECK ADD  CONSTRAINT [FK_AssetPrices_Assets] FOREIGN KEY([AssetID])
REFERENCES [dbo].[Assets] ([AssetID])
GO
ALTER TABLE [dbo].[AssetPrices] CHECK CONSTRAINT [FK_AssetPrices_Assets]
GO
 
hyperlink2  

Source Code to Index() in Controller

public ActionResult Index()
{
    // ASP.NET MVC makes it easy to pass data from a controller to a view, 
    // using the ViewData dictionary or, in the case of strongly-typed views, 
    // passing the model class directly to it
    ViewData["Message"] = "Hello from this On-Premise MVC App";
 
    return View();
}
  As explained in the video, user requests end up as calls to action methods, such as the one above, “Index().” The video then takes you to adding a data layer. The next step involves making a LINQ query in the Index() method to retrieve data and communicate that to the “Model.”
  Modifying Index() to make calls to a SQL Server database

  Snippet – Query Database
hyperlink2  

Source Code to Query Database


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
/////////////////////////////////////////////////////////////////////////////
//                Add the "using" statement
/////////////////////////////////////////////////////////////////////////////
using TierData;  // added this line
 
namespace MvcOnPremiseToCloud.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            /////////////////////////////////////////////////////////////////////////////
            //                Add the next 2 lines of code
            /////////////////////////////////////////////////////////////////////////////
            MarketIndexDataEntities _db = new MarketIndexDataEntities(); // added this line
            // We will execute a LINQ query to get data
            ViewData.Model = (from m in _db.AssetPrices select m).ToList(); // added this line
           
            // ASP.NET MVC makes it easy to pass data from a controller to a view, 
            // using the ViewData dictionary or, in the case of strongly-typed views, 
            // passing the model class directly to it
            ViewData["Message"] = "Hello from this On-Premise MVC App";
 
            return View();
        }
 
        public ActionResult About()
        {
            return View();
        }
    }
}
 
  Snippet – View Code
hyperlink2  

Source Code for the View


Snippet – Improved Table View
hyperlink2  

Source code for a better MVC table


Snippet – Improved View
hyperlink2  

Source Code for Views / Home / Index.aspx

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>
 
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Market Index Price Listing</h2>
    <table>
      <tr>
        <th> Ticker Symbol </th>
        <th> Date </th>
        <th> Open Price</th>
      </tr>
      <% foreach (TierData.AssetPrice item in (IEnumerable<TierData.AssetPrice>)(ViewData.Model))
         { %>    
      <tr>
        <td> <%= Html.DisplayFor(c => item.AssetID) %> </td>
        <td> <%= Html.DisplayFor(c => item.DatePrice)%> </td>
        <td> <%= Html.DisplayFor(c => item.OpenPrice) %></td>
      </tr>
 
      <% } %>
   </table>
 
</asp:Content>
 
Snippet – Using Statements for WebRole.cs
hyperlink2  

Source Code for WebRole.cs - Using Statements

using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
Snippet – WebRole.cs
hyperlink2  

Source Code - WebRole.cs

public class WebRole : RoleEntryPoint
   {
       public override bool OnStart()
       {
           DiagnosticMonitor.Start("DiagnosticsConnectionString");
 
           // For information on handling configuration changes
           // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
           RoleEnvironment.Changing += RoleEnvironmentChanging;
 
           return base.OnStart();
       }
 
       private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
       {
           // If a configuration setting is changing
           if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
           {
               // Set e.Cancel to true to restart this role instance
               e.Cancel = true;
           }
       }
   }