if not exists (select column_name from INFORMATION_SCHEMA.columns where table_name = '{objectQualifier}tblNaDevEventSignUpQuestion' and column_name = 'DefaultSelectOption')
 begin
   alter table {databaseOwner}[{objectQualifier}tblNaDevEventSignUpQuestion] add DefaultSelectOption bit not null default 0
 end
GO

alter procedure {databaseOwner}{objectQualifier}usp_insertEventSignUpQuestion
(
 @eventId int,
 @questionName nvarchar(255),
 @controlType nvarchar(50),
 @isRequired bit,
 @sortOrder int,
 @AskQuestionToId int,
 @DefaultSelectOption bit
)

as

set nocount on
  
	insert into {databaseOwner}[{objectQualifier}tblNaDevEventSignUpQuestion] (eventId,questionName,controlType,isRequired,sortOrder,AskQuestionToId,DefaultSelectOption)

	values (@eventId,@questionName,@controlType,@isRequired,@sortOrder,@AskQuestionToId,@DefaultSelectOption)
	
	SELECT SCOPE_IDENTITY()
			
	return

GO


alter procedure {databaseOwner}{objectQualifier}usp_updateEventSignUpQuestion
(
 @signUpQuestionId int,
 @eventId int,
 @questionName nvarchar(255),
 @controlType nvarchar(50),
 @isRequired bit,
 @sortOrder int,
 @AskQuestionToId int,
 @DefaultSelectOption bit
)

as

set nocount on
  
	update {databaseOwner}[{objectQualifier}tblNaDevEventSignUpQuestion] 
		set eventId =@eventId,
			questionName = @questionName,
			controlType = @controlType,
			isrequired = @isRequired,
			sortorder = @sortOrder,
			AskQuestionToId =@AskQuestionToId,
			DefaultSelectOption = @DefaultSelectOption

			where signUpQuestionid = @signupquestionid

GO



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

create procedure {databaseOwner}[{objectQualifier}usp_search_by_booking_name]
(
 @moduleId int
)

as

select pa.* from {databaseOwner}[{objectQualifier}tblNaDevEventsUsersSignedUpAddress] as pa
inner join {databaseOwner}[{objectQualifier}tblNaDevEventsUsersSignedUpToEvent] as b
on pa.addressId = b.billingAddressId
where moduleId = @moduleId 
and (PaymentStatusId = 1 or paymentstatusid = 7 or PaymentStatusId =9)

return 

GO