Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Duplicate Start and End Time Inetrval

Author  Topic 

Kalaiselvan
Posting Yak Master

112 Posts

Posted - 2011-09-07 : 03:45:36
Table1:
[Channel] [StartTime] [EndTime]
100 00:00:00 00:30:00
100 00:30:00 01:00:00
100 01:00:00 01:30:00
100 01:30:00 03:00:00
.....
.....
.....
100 23:00:00 24:00:00


The above Table has Channels with its Program Time Intervals. I need to check whether any Duplicates in this table for start and End Time.

For EX:
[Channel] [Start_Time] [End_Time]
100 13:00:00 14:00:00
100 13:35:00 14:15:00

The above is the Duplicate. !st row lies between 1.00PM to 2.00PM.
2nd row lies between 1.35PM to 2.15PM. This should not happens.
How to Check find these type of Duplicates. Please help me in this..

Regards,
Kalaiselvan R
Love Yourself First....

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-07 : 04:28:57
[code]select t.*
from table t
cross apply (select count(*) as cnt
from table
where t.end_time between Start_time and end_time)t1
where cnt>0
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Kalaiselvan
Posting Yak Master

112 Posts

Posted - 2011-09-07 : 07:33:20
Its not supported. Its just showing me the all values from the tables.
Please get me clear.

Regards,
Kalaiselvan R
Love Yourself First....
Go to Top of Page
   

- Advertisement -