|
|
|
|
www.thedivingclub.co.uk Joined: 9/23/2004
Posts: 3531
|
|
|
Run this in the Host/SQL dialogue with 'Execute as script' ticked - note that this fix applies to version 5.0.3 only!!
Cheers
Roger
/**** EventsGetByRange ****/
ALTER PROCEDURE {databaseOwner}[{objectQualifier}EventsGetByRange]
(
@ModuleIDs nvarchar(255),
@BeginDate datetime,
@EndDate datetime,
@CategoryName nVarchar(50)
)
AS
SET DATEFORMAT mdy
CREATE Table #EventIDs
(EventID Int, NoOfRecurrences Int, LastRecurrence DateTime)
INSERT INTO #EventIDs (EventID, NoOfRecurrences, LastRecurrence)
SELECT DISTINCT e.EventID, Count(E2.EventID) as NoOfRecurrences, Max(E2.EventDateBegin) as LastRecurrence
FROM {databaseOwner}[{objectQualifier}Events] E
LEFT OUTER JOIN {databaseOwner}[{objectQualifier}EventsMaster] M ON E.ModuleID = M.SubEventID
LEFT JOIN {databaseOwner}[{objectQualifier}Events] as E2 ON E.RecurMasterID = E2.RecurMasterID
WHERE ((E.EventTimeBegin < DATEADD(DAY,1,@EndDate) AND DATEADD(minute,E.Duration,E.EventTimeBegin) >= @BeginDate) OR
(E.EventTimeBegin >= @BeginDate AND E.EventTimeBegin < DATEADD(DAY,1, @EndDate)))
AND E.Approved = 1
AND E.Cancelled = 0
AND (E.ModuleID in (SELECT * FROM {databaseOwner}[{objectQualifier}SplitIDs](@ModuleIDs)))
GROUP By E.EventID
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,
E.CreatedByID,
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,
ET.NoOfRecurrences,
ET.LastRecurrence,
E.EnrollRoleID,
E.EnrollFee,
E.EnrollType,
E.PayPalAccount,
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.CreatedByID = 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
left join #EventIDs ET on E.EventID = ET.EventID
WHERE E.EventID in (Select EventID from #EventIDs)
AND (b.CategoryName = @CategoryName or @CategoryName = N'')
ORDER BY E.EventDateBegin, E.EventTimeBegin, E.EventDateEnd
GO
|
|
|
|
| |
|
|
|
Joined: 8/9/2007
Posts: 52
|
|
|
Although I do a lot of configuration and management, I don't do much in programming.
I went to Host/SQL - Pasted in the script above, (careful to leave out anything before the /*** and not added extra after the GO.
I checked "Run as Script" - Execute!
I got:
System.Data.SqlClient.SqlException: Line 92: Incorrect syntax near 'GO'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) /**** EventsGetByRange ****/ ALTER PROCEDURE whsb_dnn_own.[EventsGetByRange] ( @ModuleIDs nvarchar(255), @BeginDate datetime, @EndDate datetime, @CategoryName nVarchar(50) ) AS SET DATEFORMAT mdy CREATE Table #EventIDs (EventID Int, NoOfRecurrences Int, LastRecurrence DateTime) INSERT INTO #EventIDs (EventID, NoOfRecurrences, LastRecurrence) SELECT DISTINCT e.EventID, Count(E2.EventID) as NoOfRecurrences, Max(E2.EventDateBegin) as LastRecurrence FROM whsb_dnn_own.[Events] E LEFT OUTER JOIN whsb_dnn_own.[EventsMaster] M ON E.ModuleID = M.SubEventID LEFT JOIN whsb_dnn_own.[Events] as E2 ON E.RecurMasterID = E2.RecurMasterID WHERE ((E.EventTimeBegin < DATEADD(DAY,1,@EndDate) AND DATEADD(minute,E.Duration,E.EventTimeBegin) >= @BeginDate) OR (E.EventTimeBegin >= @BeginDate AND E.EventTimeBegin < DATEADD(DAY,1, @EndDate))) AND E.Approved = 1 AND E.Cancelled = 0 AND (E.ModuleID in (SELECT * FROM whsb_dnn_own.[SplitIDs](@ModuleIDs))) GROUP By E.EventID 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, E.CreatedByID, E.Every, E.Period, E.RepeatType, E.Notify, E.approved, E.Signups, E.MaxEnrollment, (Select count(*) from whsb_dnn_own.[EventsSignups] WHERE EventID = E.EventID and E.Signups = 1) as Enrolled, ET.NoOfRecurrences, ET.LastRecurrence, E.EnrollRoleID, E.EnrollFee, E.EnrollType, E.PayPalAccount, 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 whsb_dnn_own.[Modules] WHERE ModuleID = E.ModuleID) as ModuleTitle, RMOwnerID = r.OwnerID, r.RRULE, E.OriginalDateBegin, E.NewEventEmailSent FROM whsb_dnn_own.[Events] E inner join whsb_dnn_own.[EventsRecurMaster] AS r on E.RecurMasterID = r.RecurMasterID left outer join whsb_dnn_own.[Users] U on E.CreatedByID = U.UserID left outer join whsb_dnn_own.[Users] O on E.OwnerID = O.UserID left outer join whsb_dnn_own.[Users] L on E.LastUpdatedID = L.UserID left join whsb_dnn_own.[EventsCategory] b on E.Category = b.Category left join whsb_dnn_own.[EventsLocation] c on E.Location = c.Location left join #EventIDs ET on E.EventID = ET.EventID WHERE E.EventID in (Select EventID from #EventIDs) AND (b.CategoryName = @CategoryName or @CategoryName = N'') ORDER BY E.EventDateBegin, E.EventTimeBegin, E.EventDateEnd GO
I created a new host acount for you in the event that you could poke at this directly.
Appreciatively - kevin
|
|
|
|
| |
|
|
|
www.thedivingclub.co.uk Joined: 9/23/2004
Posts: 3531
|
|
|
You were so careful not to add anuything after the GO :-). Unfortunately, you need the carriage return after the GO. Add that, and all should be well.
Roger
|
|
|
|
| |
|
|
|
Joined: 8/9/2007
Posts: 52
|
|
|
The Query completed successfully!
Dang!
And the issue is gone. WOW. thank you.
|
|
|
|
| |