Click here to Skip to main content
15,914,642 members
Home / Discussions / Database
   

Database

 
GeneralRe: Connection string for database on another comouter Pin
Wendelius3-Apr-11 7:15
mentorWendelius3-Apr-11 7:15 
GeneralRe: Connection string for database on another comouter Pin
wjbjnr3-Apr-11 7:43
wjbjnr3-Apr-11 7:43 
GeneralRe: Connection string for database on another comouter Pin
Wendelius3-Apr-11 7:53
mentorWendelius3-Apr-11 7:53 
GeneralRe: Connection string for database on another comouter Pin
wjbjnr3-Apr-11 8:22
wjbjnr3-Apr-11 8:22 
GeneralRe: Connection string for database on another comouter Pin
Wendelius3-Apr-11 9:33
mentorWendelius3-Apr-11 9:33 
QuestionSQL Server Query Transportation Time Based on Latency and Internet Download Speed Pin
T21021-Apr-11 3:58
T21021-Apr-11 3:58 
AnswerRe: SQL Server Query Transportation Time Based on Latency and Internet Download Speed Pin
Wendelius1-Apr-11 6:42
mentorWendelius1-Apr-11 6:42 
GeneralRe: SQL Server Query Transportation Time Based on Latency and Internet Download Speed Pin
T21021-Apr-11 16:04
T21021-Apr-11 16:04 
GeneralRe: SQL Server Query Transportation Time Based on Latency and Internet Download Speed Pin
Wendelius1-Apr-11 20:43
mentorWendelius1-Apr-11 20:43 
Questioninvalid parameter value on CreateSubscription Pin
run4ever_771-Apr-11 2:40
run4ever_771-Apr-11 2:40 
QuestionHarmless joke or mean prank Pin
shelbypowell1-Apr-11 1:14
shelbypowell1-Apr-11 1:14 
QuestionSelecting from an XML datatype into a table Pin
Mel Padden31-Mar-11 23:47
Mel Padden31-Mar-11 23:47 
AnswerRe: Selecting from an XML datatype into a table Pin
Mel Padden1-Apr-11 0:01
Mel Padden1-Apr-11 0:01 
QuestionSQL question Pin
loyal ginger31-Mar-11 8:14
loyal ginger31-Mar-11 8:14 
QuestionRe: SQL question Pin
Jörgen Andersson31-Mar-11 8:45
professionalJörgen Andersson31-Mar-11 8:45 
GeneralRe: SQL question Pin
loyal ginger31-Mar-11 9:06
loyal ginger31-Mar-11 9:06 
GeneralRe: SQL question [modified] Pin
Jörgen Andersson31-Mar-11 9:38
professionalJörgen Andersson31-Mar-11 9:38 
Ok, this one works with your example: No it doesn't, it'll give you the combined stretches of road with gaps between them
WITH t1 AS (
    SELECT  r1.RoadID,r1.BEGIN
    FROM    Roads r1 Left outer join Roads r2
        ON  r1.RoadID = r2.RoadID
        AND r1.BEGIN > r2.BEGIN
        AND r1.BEGIN <= r2.END
    GROUP BY r1.RoadID,r1.BEGIN
    HAVING  Count(r2.BEGIN) = 0
    )
,t2 AS (
    SELECT  r3.RoadID,r3.END
    FROM    Roads r3 Left outer join Roads r4
        ON  r3.RoadID = r4.RoadID
        AND r3.END >= r4.BEGIN
        AND r3.END < r4.END
    GROUP BY r3.RoadID,r3.END
    HAVING  Count(r4.BEGIN) = 0
    )
,ContiguousStretch AS (
    SELECT  t1.RoadID,t1.BEGIN,Min(t2.END) AS END
    FROM    t1 join t2
        ON  t1.RoadID = t2.RoadID
        AND t1.BEGIN <= t2.END
    GROUP BY t1.RoadID,t1.BEGIN
    )
,Gaps AS (
    SELECT  RoadID
    FROM    ContiguousStretch
    GROUP BY RoadID
    HAVING  Count(RoadID) > 1
    )
SELECT  c.RoadID,BEGIN,END
FROM    ContiguousStretch c join gaps g
    ON  c.RoadID = g.RoadID
ORDER BY c.RoadID,BEGIN

List of common misconceptions
modified on Thursday, March 31, 2011 3:45 PM

GeneralRe: SQL question Pin
loyal ginger31-Mar-11 10:16
loyal ginger31-Mar-11 10:16 
AnswerRe: SQL question Pin
Jörgen Andersson31-Mar-11 10:28
professionalJörgen Andersson31-Mar-11 10:28 
GeneralRe: SQL question Pin
loyal ginger1-Apr-11 3:23
loyal ginger1-Apr-11 3:23 
AnswerRe: SQL question Pin
Wendelius31-Mar-11 9:14
mentorWendelius31-Mar-11 9:14 
GeneralRe: SQL question Pin
loyal ginger31-Mar-11 10:17
loyal ginger31-Mar-11 10:17 
QuestionThis one has me stumped Pin
Andy Brummer31-Mar-11 6:01
sitebuilderAndy Brummer31-Mar-11 6:01 
AnswerRe: This one has me stumped Pin
Wendelius31-Mar-11 6:45
mentorWendelius31-Mar-11 6:45 
Generalvirtual keyboard Pin
shelbypowell31-Mar-11 4:02
shelbypowell31-Mar-11 4:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.