April 2006
Intermediate to advanced
640 pages
16h 46m
English
Throughout the chapter, I will use the Performance database and its tables in my examples. Run the code in Example 3-1 to create the database and its tables, and populate them with sample data. Note that it will take a few minutes for the code to finish.
Example 3-1. Creation script for sample database and tables
SET NOCOUNT ON; USE master; GO IF DB_ID('Performance') IS NULL CREATE DATABASE Performance; GO USE Performance; GO -- Creating and Populating the Nums Auxiliary Table IF OBJECT_ID('dbo.Nums') IS NOT NULL DROP TABLE dbo.Nums; GO CREATE TABLE dbo.Nums(n INT NOT NULL PRIMARY KEY); DECLARE @max AS INT, @rc AS INT; SET @max = 1000000; SET @rc = 1; INSERT INTO Nums VALUES(1); WHILE @rc * 2 <= @max BEGIN INSERT INTO ...Read now
Unlock full access