USE [SampleDB]
GO
/****** Object: Table [dbo].[Event] Script Date: 07/27/2010 06:20:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Event](
[EventId] [bigint] IDENTITY(1,1) NOT NULL,
[EventName] [nchar](100) NOT NULL,
CONSTRAINT [PK_Event] PRIMARY KEY CLUSTERED
(
[EventId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Student] Script Date: 07/27/2010 06:20:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Student](
[StudentId] [bigint] IDENTITY(1,1) NOT NULL,
[StudentName] [nchar](100) NOT NULL,
CONSTRAINT [PK_Student] PRIMARY KEY CLUSTERED
(
[StudentId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[EventPass] Script Date: 07/27/2010 06:20:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EventPass](
[EventPassId] [bigint] IDENTITY(1,1) NOT NULL,
[EventId] [bigint] NOT NULL,
[StudentId] [bigint] NOT NULL,
CONSTRAINT [PK_EventPass] PRIMARY KEY CLUSTERED
(
[EventPassId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: StoredProcedure [dbo].[uspAddStudent] Script Date: 07/27/2010 06:20:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[uspAddStudent]
-- Add the parameters for the stored procedure here
@StudentName nchar(100)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO [dbo].[Student]
([StudentName])
VALUES(@StudentName)
END
GO
/****** Object: StoredProcedure [dbo].[uspAddEvent] Script Date: 07/27/2010 06:20:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[uspAddEvent]
-- Add the parameters for the stored procedure here
@EventName nchar(100)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO [dbo].[Event]
([EventName])
VALUES(@EventName)
END
GO
/****** Object: StoredProcedure [dbo].[uspGetEventDetails] Script Date: 07/27/2010 06:20:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[uspGetEventDetails]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT EP.[EventPassId],EP.[EventId], E.EventName, EP.[StudentId], S.StudentName
FROM [dbo].[EventPass] As EP
INNER JOIN .dbo.Student As S
ON EP.StudentId = S.StudentId
INNER JOIN .dbo.[Event] As E
ON EP.[EventId] = E.[EventId]
END
GO
/****** Object: StoredProcedure [dbo].[uspAddEventPass] Script Date: 07/27/2010 06:20:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[uspAddEventPass]
-- Add the parameters for the stored procedure here
@EventId bigint,
@StudentId bigint
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO [dbo].[EventPass]
([EventId]
,[StudentId])
VALUES
(@EventId
,@StudentId)
END
GO
/****** Object: ForeignKey [FK_EventPass_Event] Script Date: 07/27/2010 06:20:37 ******/
ALTER TABLE [dbo].[EventPass] WITH CHECK ADD CONSTRAINT [FK_EventPass_Event] FOREIGN KEY([EventId])
REFERENCES [dbo].[Event] ([EventId])
GO
ALTER TABLE [dbo].[EventPass] CHECK CONSTRAINT [FK_EventPass_Event]
GO
/****** Object: ForeignKey [FK_EventPass_Student] Script Date: 07/27/2010 06:20:37 ******/
ALTER TABLE [dbo].[EventPass] WITH CHECK ADD CONSTRAINT [FK_EventPass_Student] FOREIGN KEY([StudentId])
REFERENCES [dbo].[Student] ([StudentId])
GO
ALTER TABLE [dbo].[EventPass] CHECK CONSTRAINT [FK_EventPass_Student]
GO