USE [master]
GO
/****** Object: Database [Woodgrove] Script Date: 11/29/2006 23:38:40 ******/
CREATE DATABASE [Woodgrove] ON PRIMARY
( NAME = N'Woodgrove', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Woodgrove.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Woodgrove_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Woodgrove_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
COLLATE SQL_Latin1_General_CP1_CI_AS
GO
EXEC dbo.sp_dbcmptlevel @dbname=N'Woodgrove', @new_cmptlevel=90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Woodgrove].[dbo].[sp_fulltext_database] @action = 'disable'
end
GO
ALTER DATABASE [Woodgrove] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [Woodgrove] SET ANSI_NULLS OFF
GO
ALTER DATABASE [Woodgrove] SET ANSI_PADDING OFF
GO
ALTER DATABASE [Woodgrove] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [Woodgrove] SET ARITHABORT OFF
GO
ALTER DATABASE [Woodgrove] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [Woodgrove] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [Woodgrove] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [Woodgrove] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [Woodgrove] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [Woodgrove] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [Woodgrove] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [Woodgrove] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [Woodgrove] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [Woodgrove] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [Woodgrove] SET ENABLE_BROKER
GO
ALTER DATABASE [Woodgrove] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [Woodgrove] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [Woodgrove] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [Woodgrove] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [Woodgrove] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [Woodgrove] SET READ_WRITE
GO
ALTER DATABASE [Woodgrove] SET RECOVERY FULL
GO
ALTER DATABASE [Woodgrove] SET MULTI_USER
GO
ALTER DATABASE [Woodgrove] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [Woodgrove] SET DB_CHAINING OFF
USE [Woodgrove]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AccountInfo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AccountInfo](
[AccountNo] [int] NOT NULL,
[PIN] [smallint] NOT NULL,
CONSTRAINT [PK_AccountInfo] PRIMARY KEY CLUSTERED
(
[AccountNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AccountBalance]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AccountBalance](
[AccountNo] [int] NOT NULL,
[Balance] [money] NOT NULL,
CONSTRAINT [PK_AccountBalance] PRIMARY KEY CLUSTERED
(
[AccountNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
USE [Woodgrove]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CheckPIN]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[CheckPIN]
@AccountNo int,
@ThrowError smallint,
@TestPIN smallint,
@Valid smallint output
AS
begin
-- Set transactional isolation level
set transaction isolation level read committed
-- Don''t return record count
set nocount on
-- Throw an error if requested
if (@ThrowError > 0)
begin
raiserror(''Error requested to be thrown.'',16,-1,''CheckPIN'')
return -1
end
-- Assume failure
SET @Valid = 0
-- Pull PIN
DECLARE @PIN smallint
SET @PIN = (SELECT [PIN]
FROM [dbo].[AccountInfo]
WHERE [AccountNo] = @AccountNo)
-- Check for error
if (@PIN IS NULL)
begin
raiserror(''There is no such ac�