Preparing the Sample Database

Start by creating a basic order entry database in SQL Server. Then you’ll build application code over the database that queries and updates using each of the available data access APIs. Use either SQL Server Data Tools (SSDT) in Visual Studio (covered in Chapter 1) or SQL Server Management Studio (SSMS) to execute the script shown in Example 10-1 and create the sample database.

Example 10-1. T-SQL script for creating the SampleDb database.

USE master GO IF EXISTS(SELECT name FROM sys.databases WHERE name = 'SampleDb') DROP DATABASE SampleDb GO CREATE DATABASE SampleDb GO USE SampleDb GO CREATE TABLE Customer( CustomerId bigint IDENTITY(1,1) NOT NULL, FirstName varchar(50) NOT NULL, LastName varchar(50) NOT NULL, Balance ...

Get Programming Microsoft® SQL Server® 2012 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.