/* DB Stress Tool - Setup Author: Michael Thomas - michael@michael-thomas.com Author: Michael Thomas - michael@michael-thomas.com Original: 06/26/07 Modified: 06/26/07 Prerequisite: None. Description: Creates the DB & Table used by the test sql (sql_ex_dbstresstool_b_test.txt) */ use master IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'MyTempDB_StressTool') begin DROP DATABASE [MyTempDB_StressTool] end go create database [MyTempDB_StressTool] go use MyTempDB_StressTool if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MyStressData]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[MyStressData] go CREATE TABLE [dbo].[MyStressData] ( [id] [int] NOT NULL , [row] [int] NOT NULL , [code] [char] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [description] [nchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] go SET NOCOUNT ON DECLARE @intMaxRows_default int set @intMaxRows_default = 100000 -- (100,000) # of rows that will be created for the base data. DECLARE @intMaxRows int DECLARE @intRow int, @strCode char(30), @strDescription nvarchar(255) DECLARE @strDescriptionText nvarchar(255) set @intMaxRows = @intMaxRows_default set @strDescriptionText = 'Default: This is a stress test #: ' SET @intRow = 1 WHILE @intRow <= @intMaxRows BEGIN set @strCode = 'Default:' + convert(nvarchar(30), @intRow) set @strDescription = @strDescriptionText + convert(nvarchar(30), @intRow) insert into MyStressData ( id, row, code, description ) values (@intRow, @intRow, @strCode, @strDescription) SET @intRow = @intRow + 1 END SET NOCOUNT OFF PRINT 'Finished DB & Table Setup. Created ' + convert(nvarchar(30), @intMaxRows) + ' base rows of data.' use master GO -- select count(*) from MyStressData -- select * from MyStressData