Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Statement for Checking for a conflict
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00594598
Message ID:
00594611
Views:
14
This message has been marked as the solution to the initial question of the thread.
Try
AND ( (@ttStart Between begintime And endtime) OR 
         (@ttEnd Between begintime And endtime) )
>I have the following stored procedure that I tried to determine if a scheduled event overlaps another scheduled event for the same surgeon. It will return a result set (conflict exists) if the the endtime or begintime are between another scheduled event. BUT it won't return a conflict (and I want it to) if the case is between the begin and endtime of another case.
>
>Event1 starts at 08:00 and end at 10:00
>If I try to put another event that only lasts an hour between 8:30 and 9:30 then it does not show a conflict.
>
>
>CREATE PROCEDURE ct_Con_SurgeonCase
>@tiMeetID int,
>@tiDocID int,
>@ttStart datetime,
>@ttEnd datetime
>
>as
>
>
>SELECT   < some fields >
< snip >
>FROM         dbo.meetings INNER JOIN
>     dbo.meetproc ON dbo.meetings.meetingnumber = dbo.meetproc.meetingnumber
>WHERE   dbo.meetings.meetingnumber != @tiMeetID
>AND         dbo.meetproc.coPerID = @tiDocID
>AND         (begintime BETWEEN @ttStart AND @ttend OR endtime BETWEEN @ttStart and @ttEnd)
>GO
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform