Roger thank for your help and patience with all this.
When trying to add the conditional statement I get this error.
Msg 137, Level 15, State 2, Procedure EventsGetByRange, Line 14
Must declare the scalar variable "@ModuleIds".
Thats what made me think I had to declare it. The first part of my SQL is below...
ALTER PROCEDURE [dbo].[EventsGetByRange]
(
@Filter nvarchar(500),
@BeginDate datetime,
@EndDate datetime
)
AS
SET DATEFORMAT mdy
IF @ModuleIDs = N'618'
Select @BeginDate = '2012-01-01'
Select @EndDate = '2012-12-31'
Declare @sql nvarchar(4000)
Select @sql = 'SELECT E.PortalID, E.EventID, E.RecurMasterID, E.ModuleID, E.EventDateBegin, E.EventDateEnd, '
+ 'E.EventTimeBegin, E.Duration, E.EventName, E.EventDesc, '
+ 'E.Importance, E.CreatedDate, '
+ 'CreatedBy = U.DisplayName, '
+ 'CreatorID = E.CreatedBy, '
+ 'E.Every, '
+ 'E.Period, '
+ 'E.RepeatType, '
+ 'E.Notify, '
+ 'E.approved, '
+ 'E.Signups, '
......