I am using SQL Server 2016 (localDB). I have the following DB script which takes 8 seconds, however, the select
statement only take 0 seconds if I run separately. Actually that select
statement always return 0 rows.
Do you know why it is slow in this case?
PS: I have another similar statement, which works fine, only this one takes super long.
while exists (select *
from vidyoRoomCall vrc
inner join reportEffectiveRoomUsage eu on vrc.vidyoRoomId = eu.vidyoRoomId
and vrc.leaveTime is not null
and datediff(second, vrc.joinTime, vrc.leaveTime) < 100000 -- @max_second
where (vrc.joinTime between eu.[start] and eu.[end]
and vrc.leaveTime > eu.[end])
or (vrc.leaveTime between eu.[start] and eu.[end]
and vrc.joinTime < eu.[start])
)
begin
print 'ignore this since it is only run here' -- this never print
end