Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Better way ?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
01051712
Message ID:
01051720
Vues:
14
The first two checks are unnecessary
		where  (@StartTime between begintime and endtime
	        	or dateadd(mi,@ilength,@StartTime) between begintime and endtime)
	        	and iscancelled=0 and roomid = @RoomID 
>I have this function that checks for conflicts, but it is not very fast, does anyone have a better sugguestion on how to code this? If I take out the or clauses, it performs fast, but I'm afraid it could allow for conflicts without the other checks.
>
>
>
>CREATE FUNCTION ctFun_RoomConflictA  (@RoomID int, @iLength int, @StartTime datetime )
>RETURNS int as
>BEGIN
>     Declare @returnValue int
>        select  @returnValue=
>	  (select count(meetingnumber) from dbo.meetings
>		where (begintime between @StartTime and dateadd(mi,@iLength,@StartTime)
>	        or     endtime   between @StartTime and dateadd(mi,@iLength,@StartTime)
>	        	or @StartTime between begintime and endtime
>	        	or dateadd(mi,@ilength,@StartTime) between begintime and endtime)
>	        	and iscancelled=0 and roomid = @RoomID )
>      return (@returnValue)
>END
>
>
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform