The following script generates the data required for the performance testing of TSQL Challenge 18.
/***********************************************************************
----------------------------------------------
Performance Testing Data for TSQL Challenge 18
Copyright © beyondrelational.com
----------------------------------------------
Notes:
1. The following script is used to generate the performance testing
data for TSQL Challenge 18.
2. The script given below generates a table representing all the
Months and years in the last century (From January 1900 to
December 1999)
Revision History:
Rev 00 - 30 March 2010 - Jacob Sebastian - Initial Release
***********************************************************************/
DECLARE @t TABLE (Mth INT, Yr INT)
;WITH years AS (
SELECT
1900 + Number AS Yr
FROM master..spt_values
WHERE TYPE = 'P' AND Number BETWEEN 0 AND 99
), months AS (
SELECT
Number AS Mth
FROM master..spt_values
WHERE TYPE = 'P' AND Number BETWEEN 1 AND 12
)
INSERT INTO @t(Mth, Yr)
SELECT
Mth,
Yr
FROM years
CROSS JOIN months