Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Possible better way
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01342342
Message ID:
01342386
Views:
13
Doesn't make much sense to me either. May be they were trying to prevent NULLS passed as parameters?

>Well that didn't make any difference. But for some reason the guys who coded the stored procedure are not using the passed in parameters directly, but are running them through a convert() process to locally declared variables.
>
>
>CREATE PROCEDURE [dbo].[ctx_Personnel_WithRoomConflict_GetByTypeIdDepartmentIdAndDateRange]
>@PersonnelTypeId INT,
>@DepartmentId INT,
>@ExcludedCaseId INT,
>@CaseStartDateTime DATETIME,
>@CaseEndDateTime DATETIME
>AS
>
>SET NOCOUNT ON
>
>DECLARE @Start DATETIME
>DECLARE @End DATETIME
>
>SET @Start = CONVERT(DATETIME, CONVERT(varchar, @CaseStartDateTime, 100))
>SET @End = CONVERT(DATETIME, CONVERT(varchar, @CaseEndDateTime, 100))
>
>
>
>Changing the where clause to use the Passed Parameters instead seem to make a HUGE difference. Not sure why they have it coded this way or why it makes such a difference.
>
>
>WHERE
>	m.meetingnumber <> @ExcludedCaseId
>	AND
>	(
>		(@CaseStartDateTime > m.begintime AND @CaseStartDateTime < m.endtime)
>		OR (@CaseEndDateTime > m.begintime AND @CaseEndDateTime < m.endtime)
>		OR (m.begintime > @CaseStartDateTime AND m.begintime < @CaseEndDateTime)
>		OR (m.endtime > @CaseStartDateTime AND m.endtime < @CaseEndDateTime)
>		OR(@CaseStartDateTime = m.begintime AND @End = m.endtime)
>	)
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform