Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Possible better way
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01342342
Message ID:
01342385
Vues:
16
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)
	)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform