I did as you instructed but cannot find Create to Alter in the lines you told me to copy. This is what I have...
CREATE PROCEDURE {databaseOwner}{objectQualifier}EventsGetByRange
(
@Filter nvarchar(1024),
@BeginDate datetime,
@EndDate datetime
)
AS
SET DATEFORMAT mdy
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, '
+ 'E.MaxEnrollment, '
+ '(Select count(*) from {databaseOwner}{objectQualifier}EventsSignups WHERE EventID = E.EventID and E.Signups = 1) as Enrolled, '
+ '(Select count(*) from {databaseOwner}{objectQualifier}Events as E2 WHERE E2.RecurMasterID = E.RecurMasterID and E2.Cancelled = 0 and E2.Approved = 1) as NoOfRecurrences, '
+ '(Select max(EventDateBegin) from {databaseOwner}{objectQualifier}Events as E2 WHERE E2.RecurMasterID = E.RecurMasterID and E2.Cancelled = 0 and E2.Approved = 1) as LastRecurrence, '
+ 'E.EnrollRoleID, '
+ 'E.EnrollFee, '
+ 'E.EnrollType, '
+ 'E.PayPalAccount, '
+ 'E.PayPalPassword, '
+ 'E.Cancelled, '
+ 'E.DetailPage, '
+ 'E.DetailNewWin, '
+ 'E.DetailURL, '
+ 'E.ImageURL, '
+ 'E.ImageType, '
+ 'E.ImageWidth, '
+ 'E.ImageHeight, '
+ 'E.ImageDisplay, '
+ 'E.Location, '
+ 'c.LocationName, '
+ 'c.MapURL, '
+ 'E.Category, '
+ 'b.CategoryName, '
+ 'b.Color, '
+ 'b.FontColor, '
+ 'E.Reminder, '
+ 'E.TimezoneOffset, '
+ 'E.SendReminder, '
+ 'E.ReminderTime, '
+ 'E.ReminderTimeMeasurement, '
+ 'E.ReminderFrom, '
+ 'E.SearchSubmitted, '
+ 'E.CustomField1, '
+ 'E.CustomField2, '
+ 'E.EnrollListView, '
+ 'E.DisplayEndDate, '
+ 'E.AllDayEvent, '
+ 'E.OwnerID, '
+ 'OwnerName = O.DisplayName, '
+ 'E.LastUpdatedAt, '
+ 'LastUpdatedBy = L.DisplayName, '
+ 'E.LastUpdatedID, '
+ '(Select ModuleTitle from {databaseOwner}{objectQualifier}Modules WHERE ModuleID = E.ModuleID) as ModuleTitle, '
+ 'RMOwnerID = r.OwnerID, '
+ 'r.RRULE, '
+ 'E.OriginalDateBegin, '
+ 'E.NewEventEmailSent '
+ 'FROM {databaseOwner}{objectQualifier}Events E '
+ 'inner join {databaseOwner}{objectQualifier}EventsRecurMaster AS r on E.RecurMasterID = r.RecurMasterID '
+ 'left outer join {databaseOwner}{objectQualifier}Users U on E.CreatedBy = U.UserID '
+ 'left outer join {databaseOwner}{objectQualifier}Users O on E.OwnerID = O.UserID '
+ 'left outer join {databaseOwner}{objectQualifier}Users L on E.LastUpdatedID = L.UserID '
+ 'left join {databaseOwner}{objectQualifier}EventsCategory b on E.Category = b.Category '
+ 'left join {databaseOwner}{objectQualifier}EventsLocation c on E.Location = c.Location '
+ 'WHERE ((E.EventTimeBegin <= DATEADD(DAY,1,''' + convert(varchar, @EndDate) + ''') AND DATEADD(minute,E.Duration,E.EventTimeBegin) >= ''' + convert(varchar, @BeginDate) + ''') OR '
+ ' (E.EventTimeBegin BETWEEN ''' + convert(varchar, @BeginDate) + ''' AND DATEADD(DAY,1,''' + convert(varchar, @EndDate) + '''))) '
+ ' AND E.Approved = 1'
+ ' AND E.Cancelled = 0'
+ ' ' + @Filter + ' '
+ ' ORDER BY E.EventDateBegin, E.EventTimeBegin, E.EventDateEnd'
EXEC (@sql)
GO
I really appreciate your help!
-Ran
|