SQL 判断是否存在时间交叉

if exists(
select 1 
from Tb_Test 
where (BeginTime between '2012-5-2' and '2012-6-2')
    or(EndTime between '2012-5-2' and '2012-6-2') 
    or('2012-6-2' between BeginTime and EndTime)
    or('2012-5-2' between BeginTime and EndTime) )
print '时间存在交叉'

 

posted @ 2012-04-13 16:16  AlanCoder  阅读(649)  评论(0编辑  收藏  举报
View Code