日期:2014-05-16 浏览次数:20524 次
--> 测试数据[huang]
if object_id('[huang]') is not null drop table [huang]
go
create table [huang]([id] int,[begintime] datetime,[endtime] datetime)
insert [huang]
select 1,'2014-04-18 10:00:00','2014-04-18 10:50:00' union all
select 1,'2014-04-18 10:30:00','2014-04-18 11:00:00' union all
select 1,'2014-04-18 10:10:00','2014-04-18 12:30:00' union all
select 1,'2014-04-18 10:10:00','2014-04-18 12:30:00' union all
select 1,'2014-04-18 11:30:00','2014-04-18 12:00:00' union all
select 1,'2014-04-18 11:30:00','2014-04-18 12:00:00' union all
select 1,'2014-04-18 15:30:00','2014-04-18 16:00:00'
union all
select 2,'2014-04-18 15:30:00','2014-04-18 16:00:00'
UNION ALL
select 2,'2014-04-18 10:00:00','2014-04-18 10:50:00' union all
select 2,'2014-04-18 10:30:00','2014-04-18 11:00:00' union all
select 2,'2014-04-18 10:10:00','2014-04-18 12:30:00' union all
select 2,'2014-04-18 10:10:00','2014-04-18 12:30:00' union all
select 2,'2014-04-18 11:30:00','2014-04-18 12:00:00' union all
select 2,'2014-04-18 11:30:00','2014-04-18