
-- SQLAzureMWParseTSQL TSQL Output File:
-- Generated at: 3/1/2014 3:07:20 PM

if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}tblNaDevEventsInRoles]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table {databaseOwner}[{objectQualifier}tblNaDevEventsInRoles]
GO

CREATE TABLE {databaseOwner}[{objectQualifier}tblNaDevEventsInRoles] (
	[eventRoleId] [int] IDENTITY (1, 1) NOT NULL ,
	[eventId] [int]NOT NULL,
	[roleName] [nvarchar] (256)NOT NULL
    constraint [PK_{objectQualifier}tblNaDevEventsInRoles] primary key clustered
	(
		[eventRoleId] asc
	)
)
GO

if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}usp_insertEventsInRoles]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure {databaseOwner}{objectQualifier}usp_insertEventsInRoles
GO

create procedure {databaseOwner}{objectQualifier}usp_insertEventsInRoles
(
 @eventId int,
 @roleName nvarchar(256)
)

as

set nocount on
  
	insert into {databaseOwner}[{objectQualifier}tblNaDevEventsInRoles] (eventId, roleName)

	values (@eventId, @roleName)

GO

if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}usp_deleteAllRolesForEvent]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure {databaseOwner}{objectQualifier}usp_deleteAllRolesForEvent
GO

create procedure {databaseOwner}{objectQualifier}usp_deleteAllRolesForEvent
(
 @eventId int
)

as

set nocount on
  
	delete from {databaseOwner}[{objectQualifier}tblNaDevEventsInRoles] where eventId = @eventId

GO

if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}usp_getAllRolesForEvent]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure {databaseOwner}{objectQualifier}usp_getAllRolesForEvent
GO

create procedure {databaseOwner}{objectQualifier}usp_getAllRolesForEvent
(
 @eventId int
)

as

set nocount on
  
	select * from {databaseOwner}[{objectQualifier}tblNaDevEventsInRoles] where eventId = @eventId

GO
