www.pudn.com > ADO 2.6 Programmers Reference(Source Code).zip > ADOPerf.sql


/* Microsoft SQL Server - Scripting			*/ 
/* Server: PIGLET					*/ 
/* Database: ADOPerf					*/ 
/* Creation Date 8/21/98 8:54:49 AM 			*/ 
 
/****** Object:  Stored Procedure dbo.usp_FillTable    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.usp_FillTable') and sysstat & 0xf = 4) 
	drop procedure dbo.usp_FillTable 
GO 
 
/****** Object:  Stored Procedure dbo.usp_FillTables    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.usp_FillTables') and sysstat & 0xf = 4) 
	drop procedure dbo.usp_FillTables 
GO 
 
/****** Object:  Table dbo.tblFiftyThousand    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.tblFiftyThousand') and sysstat & 0xf = 3) 
	drop table dbo.tblFiftyThousand 
GO 
 
/****** Object:  Table dbo.tblFiveHundred    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.tblFiveHundred') and sysstat & 0xf = 3) 
	drop table dbo.tblFiveHundred 
GO 
 
/****** Object:  Table dbo.tblFiveThousand    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.tblFiveThousand') and sysstat & 0xf = 3) 
	drop table dbo.tblFiveThousand 
GO 
 
/****** Object:  Table dbo.tblHundredThousand    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.tblHundredThousand') and sysstat & 0xf = 3) 
	drop table dbo.tblHundredThousand 
GO 
 
/****** Object:  Table dbo.tblOneHundred    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.tblOneHundred') and sysstat & 0xf = 3) 
	drop table dbo.tblOneHundred 
GO 
 
/****** Object:  Table dbo.tblOneThousand    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.tblOneThousand') and sysstat & 0xf = 3) 
	drop table dbo.tblOneThousand 
GO 
 
/****** Object:  Table dbo.tblTenThousand    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.tblTenThousand') and sysstat & 0xf = 3) 
	drop table dbo.tblTenThousand 
GO 
 
/****** Object:  Default dbo.UW_ZeroDefault    Script Date: 21/08/98 08:54:50 ******/ 
if exists (select * from sysobjects where id = object_id('dbo.UW_ZeroDefault') and sysstat & 0xf = 6) 
	drop default dbo.UW_ZeroDefault 
GO 
 
/****** Object:  Default dbo.UW_ZeroDefault    Script Date: 21/08/98 08:54:50 ******/ 
CREATE DEFAULT dbo.UW_ZeroDefault AS 0 
GO 
 
/****** Object:  Table dbo.tblFiftyThousand    Script Date: 21/08/98 08:54:51 ******/ 
CREATE TABLE dbo.tblFiftyThousand ( 
	Key_ int IDENTITY (1, 1) NOT NULL , 
	Description varchar (50) NULL , 
	ForeignKey int NULL , 
	TextField varchar (10) NULL , 
	CurrencyField money NULL , 
	BitField bit NOT NULL  
) 
GO 
 
setuser 'dbo' 
GO 
 
EXEC sp_bindefault 'dbo.UW_ZeroDefault', 'tblFiftyThousand.BitField' 
GO 
 
setuser 
GO 
 
/****** Object:  Table dbo.tblFiveHundred    Script Date: 21/08/98 08:54:51 ******/ 
CREATE TABLE dbo.tblFiveHundred ( 
	Key_ int IDENTITY (1, 1) NOT NULL , 
	Description varchar (50) NULL , 
	ForeignKey int NULL , 
	TextField varchar (10) NULL , 
	CurrencyField money NULL , 
	BitField bit NOT NULL  
) 
GO 
 
setuser 'dbo' 
GO 
 
EXEC sp_bindefault 'dbo.UW_ZeroDefault', 'tblFiveHundred.BitField' 
GO 
 
setuser 
GO 
 
/****** Object:  Table dbo.tblFiveThousand    Script Date: 21/08/98 08:54:52 ******/ 
CREATE TABLE dbo.tblFiveThousand ( 
	Key_ int IDENTITY (1, 1) NOT NULL , 
	Description varchar (50) NULL , 
	ForeignKey int NULL , 
	TextField varchar (10) NULL , 
	CurrencyField money NULL , 
	BitField bit NOT NULL  
) 
GO 
 
setuser 'dbo' 
GO 
 
EXEC sp_bindefault 'dbo.UW_ZeroDefault', 'tblFiveThousand.BitField' 
GO 
 
setuser 
GO 
 
/****** Object:  Table dbo.tblHundredThousand    Script Date: 21/08/98 08:54:52 ******/ 
CREATE TABLE dbo.tblHundredThousand ( 
	Key_ int IDENTITY (1, 1) NOT NULL , 
	Description varchar (50) NULL , 
	ForeignKey int NULL , 
	TextField varchar (10) NULL , 
	CurrencyField money NULL , 
	BitField bit NOT NULL  
) 
GO 
 
setuser 'dbo' 
GO 
 
EXEC sp_bindefault 'dbo.UW_ZeroDefault', 'tblHundredThousand.BitField' 
GO 
 
setuser 
GO 
 
/****** Object:  Table dbo.tblOneHundred    Script Date: 21/08/98 08:54:52 ******/ 
CREATE TABLE dbo.tblOneHundred ( 
	Key_ int IDENTITY (1, 1) NOT NULL , 
	Description varchar (50) NULL , 
	ForeignKey int NULL , 
	TextField varchar (10) NULL , 
	CurrencyField money NULL , 
	BitField bit NOT NULL  
) 
GO 
 
setuser 'dbo' 
GO 
 
EXEC sp_bindefault 'dbo.UW_ZeroDefault', 'tblOneHundred.BitField' 
GO 
 
setuser 
GO 
 
/****** Object:  Table dbo.tblOneThousand    Script Date: 21/08/98 08:54:52 ******/ 
CREATE TABLE dbo.tblOneThousand ( 
	Key_ int IDENTITY (1, 1) NOT NULL , 
	Description varchar (50) NULL , 
	ForeignKey int NULL , 
	TextField varchar (10) NULL , 
	CurrencyField money NULL , 
	BitField bit NOT NULL  
) 
GO 
 
setuser 'dbo' 
GO 
 
EXEC sp_bindefault 'dbo.UW_ZeroDefault', 'tblOneThousand.BitField' 
GO 
 
setuser 
GO 
 
/****** Object:  Table dbo.tblTenThousand    Script Date: 21/08/98 08:54:52 ******/ 
CREATE TABLE dbo.tblTenThousand ( 
	Key_ int IDENTITY (1, 1) NOT NULL , 
	Description varchar (50) NULL , 
	ForeignKey int NULL , 
	TextField varchar (10) NULL , 
	CurrencyField money NULL , 
	BitField bit NOT NULL  
) 
GO 
 
setuser 'dbo' 
GO 
 
EXEC sp_bindefault 'dbo.UW_ZeroDefault', 'tblTenThousand.BitField' 
GO 
 
setuser 
GO 
 
/****** Object:  Stored Procedure dbo.usp_FillTable    Script Date: 21/08/98 08:54:52 ******/ 
CREATE PROCEDURE usp_FillTable 
	@sTable	varchar(25), 
	@iTimes	int 
AS 
BEGIN 
	SET NOCOUNT ON 
 
	DECLARE @iLoop	int 
	DECLARE @sCmd	varchar(255) 
	DECLARE @sLoop	varchar(6) 
	DECLARE @sQuote	char(1) 
 
	SELECT @iLoop = 0 
	SELECT @sQuote = char(39) 
 
	WHILE @iLoop < @iTimes 
	BEGIN 
		SELECT @sLoop = CONVERT (varchar(6), @iLoop) 
 
		SELECT @sCmd = 'INSERT INTO ' 
			+ @sTable 
			+ ' VALUES (' 
			+ @sQuote + 'Table ' + @sTable + ': Record ' + @sLoop + @sQuote 
			+ ', ' + @sLoop 
			+ ', ' + @sQuote + 'Rec' + @sLoop + @sQuote 
			+ ', ' + @sLoop 
			+ ', 0' 
			+ ')' 
 
		EXEC (@sCmd) 
 
		SELECT @iLoop = @iLoop + 1  
	END 
 
	SET NOCOUNT OFF 
 
	SELECT 'Inserted ' + CONVERT (varchar, @iTimes) + ' records into ' + @sTable 
END 
GO 
 
/****** Object:  Stored Procedure dbo.usp_FillTables    Script Date: 21/08/98 08:54:52 ******/ 
CREATE PROCEDURE usp_FillTables 
as 
BEGIN 
	EXEC usp_FillTable 'tblOneHundred', 100 
	EXEC usp_FillTable 'tblFiveHundred', 500 
	EXEC usp_FillTable 'tblOneThousand', 1000 
	EXEC usp_FillTable 'tblFiveThousand', 5000 
	EXEC usp_FillTable 'tblTenThousand', 10000 
	EXEC usp_FillTable 'tblFiftyThousand', 50000 
	EXEC usp_FillTable 'tblHundredThousand', 100000 
END 
GO