Finding Completely Overlapping Segments

Jun 5, 2008

ok folks, I need help.

Here's the table and some sample data:


declare @t table
(
segment int,
subsegment int,
primary key (segment,subsegment)
)
insert @t
select 1,33 union all
select 1,22 union all
select 2,33 union all
select 2,22 union all
select 3,33 union all
select 3,22 union all
select 3,44


What I want is to find all segments that are in some sense complete duplicates of other segments. a segment is made up of subsegments. a subsegment is not a segment - it's a completely different entity. this table is not hierarchical.

So in the sample data above, segments 1 and 2 are dupes because they share exactly the same subsegments: 22 and 33. Segment 3 is not a dupe because it has a third subsegment the other two don't have: 44.

when a duped segment is found, I need to know which other segment it duplicates. so an acceptable result set for the above sample data would be:


segment partner
------- -------
1 2


this would also be fine:


segment partner
------- -------
1 2
2 1


ps: i already posted this on dbforums - just broadening the audience a little.

elsasoft.org

View 20 Replies


ADVERTISEMENT

T-SQL (SS2K8) :: Finding Out Missing Segments From Source Dataset

Oct 23, 2014

I have 2 tables, #MainSample and #SampleCode

In the #MainSample, Line_ID is the Primary key

Line_ID BegMeasure EndMeasure

656 0.00 254500.00
657 0.00 7000.00
658 0.00 308000.00
659 0.00 20000.00

#Sample Code

Line_ID BegMeasure EndMeasure Code

659 665.00 9456.00 APL-XL
657 0.00 200 BHP

From this, I have to find out the segments for which there is no defined code value. I want the output as

Line_ID BegMeasure EndMeasure

656 0.00 254500.00
657 200.00 7000.00
658 0.00 308000.00
659 0.00 665.00
659 9456.00 20000.00

How to achieve this?

View 0 Replies View Related

Changing Network Segments

Aug 6, 1998

When we move our SQL server 6.5 to a new network segment, our applications cannot connect to it anymore. Any ideas?

View 3 Replies View Related

Disecting Date Into Segments

Jul 20, 2005

I have a date that I get from my now() function that returns:2/10/2004 2:17:16 PMI would like to be able to break this value up. Is there a function thatallows me to pull whatever I want out of this?For example, if I just want the year 2004 pulled out (for a drop downlist I'm creating) what would the function be to do that?And If I just want the day, 10 pulled out, then how would I do that?part of the problem is that depending on the month, is the number ofdigits one counts from the front. 10,11,12 add one digit to the front ofthe string, making this difficult.I'm creating a search between dates so someone can select the day, monthand year as beginning value, and the end value. So how would I go aboutdisecting this string?Thanks,Bill*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 2 Replies View Related

SQL Server 2012 :: Getting End Dates For History Segments?

Aug 14, 2014

I have a customer history table with the follow structure and data:

CustomerID Tier StartDate RecordStatus

123 A 01/01/2013

View 3 Replies View Related

SQL Server 2012 :: Getting End Dates For History Segments

Aug 14, 2014

I have a customer history table with the follow structure and data:

CustomerID Tier StartDate RecordStatus

123 A 01/01/2013 1
123 A 03/01/2013 0
123 B 03/01/2013 1
123 B 06/01/2013 0
123 A 08/01/2014 1
456 C 02/01/2014 1

CREATE TABLE TEMPHISTORY(
CUSTOMERID VARCHAR(11),
TIER VARCHAR(10),
STARTDATE DATE,
RECORDSTATUS TINYINT)

[Code] .....

The RECORDSTATUS value of 1 means the record is active. A corresponding record of the same CustomerID, Tier. in startdate chronology, with a value of 0 indicates that the previous record with the status of 1 has now terminated and the startdate of the record with recordstatus of 0 is the start date of the termination of the previous record, or better stated, the end date of the previous record.

What I need to do is re-record the above data the startdate of each terminated record become an enddate for the previous record, minus 1 day, as follows:

CUSTOMERID TIER STARTDATE ENDDATE
123 A 01/01/2013 02/28/2013
123 B 03/01/2013 05/31/2013
123 A 08/01/2014 NULL
456 C 02/01/2014 NULL

View 1 Replies View Related

Pulling Variable Number Of Segments Out Of Data

Mar 19, 2008

I've got a table full of data like so:

varchar(MAX) as
'MSG|John|J|Smith EVN|2008-02-01|A03 ADD|101 Highland St|Mount Vernon|WA|55231 OBS|Flu|Severe OBS|Mumps|Mild'

To explain this more thoroughly, the data is organized into segments: MSG, EVN, ADD, and OBS.

Each message may have 1+ of each of these segments.

What I'd like to do is pull the contents of all OBS segments and put them into a table.

I know I can identify them using the regex of ' OBS|' but I'm not clear on how to capture anything but the first one easily. Programmatically, it's simple. SQL I'm not so sure.

Can anyone give me a gentle nudge in the right direction?

Thanks!

View 2 Replies View Related

Am Completely Lost

Jun 10, 2006

Hello all let me first start out by saying I suck at SQL.  I can do quite a bit with ASP.NET but SQL Server is on area that has haunted me and I have finally decided to bite the bullet and figure this behamouth out.Well here is my first problem, which is the biggest reason I can't seem to understand SQL Server or dataases in general.To have a realtional database you set up tables with foriegn keys and primary keys referenceing the id's like product table has a product name and one of the columns is a user_id displaying the id number of the user in the user table.  From what I can tell you are supposed to set up the user_id in the products table a foriegn key to the Primary Key in the user table.   I may be totally wrong on this though.Now my biggest question is how do you retrive this information the proper way to get it ready to be displayed in a gridveiw or a datalist?  I have been reading SQL Server 2005 for developers and reading online tutorials and it seems like they say you need to set up a relationship and because of the realtionship you don't need to do a join, but I never hear how to use the relationship at all.Please someone help I am so totally lost that i feel like i will never understand. I have spent the last week trying to figure this out and I guess I am just googleing this wrong completely or i am incompentent one of the two.Thank you.

View 1 Replies View Related

Overlapping Sets

Apr 24, 2007

I have the following table structure

CREATE TABLE [dbo].[QDisc](
[Id] [int] NOT NULL,
[MinVal] [int] NOT NULL,
[MaxVal] [int] NOT NULL,
[PerVal] [int] NOT NULL,
CONSTRAINT [PK_QDisc] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

I need to be able to select unique overlapping sets of data based on the minval and maxval.

Simple Example
minval maxval
5 15
16 25
10 20

query would produce
minval maxval
5 10
11 15
16 20
21 25

More Complex example
minval maxval
5 15
16 25
10 20
7 7
1 100

query would produce
minval maxval
1 5
6 6
7 7
8 10
11 15
16 20
21 25
26 100

Extra points if anyone can do this without SP and cursor but I'd be satisfied if someone supplied it that way.

View 9 Replies View Related

Date Overlapping

Oct 4, 2006

i have a table containing following dataeffdate termdate uid----------- ----------- -----------1 2 13 4 25 8 37 9 411 12 512 13 63 6 75 9 8i need to replace all the overlapping records with one recordsuch that resultant table shud look likeeffdate termdate uid1 2 111 13 23 9 3Thanks

View 8 Replies View Related

T-SQL Overlapping Time

Aug 28, 2006

I have a table with following fields

CURRENT_DAY FROM_DATE TO_DATE

1 1899-12-20 09:00:00.000 1899-12-20 10:00:00.000

1 1899-12-20 09:50:00.000 1899-12-20 11:00:00.000

1 1899-12-20 12:00:00.000 1899-12-20 02:00:00.000

I need the count of records that overlap with each other. [OR]

1 if there is overlap, 0 if there is no overlap.

I am new to sql, thanks for any help.

Yog

View 2 Replies View Related

How To Completely Remove MSDE

Mar 1, 2004

I need to completly remove MSDE from my PC it was installed using Install Shield Express and when I try to uninstall, I get a Fatal error durring installation. There must be a way other than reformatting?

Thank you,

View 1 Replies View Related

Won't Let Me Completely Install The Server. PLEASE HELP!

May 23, 2005

I installed sql2ksp3 from the CD I received in my ASP.net book. The installation went fine and then I went to the DOS prompt and did the setup SAPWD and it ran. I restarted my computer and opened ASP Matrix and went to the Data tab and proceed to connect to the server. It gave me an error message it couldn't connect. So I uninstalled MSDE and made sure the sql2ksp3 folder was gone. So I went ahead and installed the sql2ksp3 from the CD again and then went to DOS to do the setup. It ran through the setup until the very end, saying it couldn't setup the server. I have tried it several times and it always stops around 11 seconds. I have tried to install the download from microsoft instead the CD and that didn't work also. So at this point I am stuck. PLEASE HELP!

View 7 Replies View Related

Backup Jobs Overlapping

Feb 7, 2000

I have 3 seperate jobs to backup my database. 1 for a full backup, 1 for differentials, and the 3rd for the transaction log. Each is on its own schedule. The problem I have is that sometimes the transaction log job will try to start while one of the other two are in process. When this happens, an error is generated and I get paged (which is very anoying at midnight) Is there any way to block the transaction job until the other two are complete? It should still run, just not at the same time.

View 1 Replies View Related

How To Remove Replication Completely?

Sep 25, 2001

When i uninstall replication, it failed to remove completely. How do i remove them completely. so that make replication again

I would appriciate any help.

Thanks in advance

Yads

View 1 Replies View Related

Overlapping Integer Ranges ??

Jul 26, 2004

:confused: Dont know if this will be tough for the rest of you but for someone who is fairly new to SQL...I cannot figure it out...

I have a table:

Rownumber starttime endtime
1 l 30 l 240
2 l 40 l 120
3 l 50 l 260
4 l 1300 l 1400


Rows 1, 2, and 3 over lap with one another and I am trying to obtain the starttime and endtime values which can cover them all.

I would like to find the overlapping (starttime - endtime) ranges and accept the lowest starttime value and the highest endtime value.

Row 1: 30--------------------240
Row 2: 40--------------120
Row 3: 50----------------------260
Row 4: ...1300---------1440


I would like to include starttime-endtime ranges that do not overlap with any other integer range.

which in this case would be:

Rownumber starttime endtime
1 l 30 l 260
2 l 1330 l 1400

I was thinking of using a cursor and comparing each row to all of the other rows in the table and then setting a boolean in that row if it overlaps with another row in the table...is there a better way of doing this?

Thank you for the help!

View 14 Replies View Related

Date Ranges Overlapping

Oct 25, 2005

I've gone cold here. Dunno if I've had too little coffee - as I'm currently drinking some seriously wicked green tea - or whether my brain has locked down from yesterdays "bad eggs for lunch" experience.

Anyway... I have database with a customer, for each customer is a related history table with assigned consultant.

The assigned consultant table has information on consultant id, name, the start date of his assignment and the end date.

I need to find all customers that currently have (or have had) two or more consultants actively assigned. In other words, I need to see if the start/end times overlap.

At my current state, I'm just done.. i can't maintain the perspective... how do I do this?

View 5 Replies View Related

Completely Remove SQL 2005

Aug 30, 2007

Hi,
Can any 1 guide me how to completely remove SQL 2005 ?

Currrently i have a problem to install SQL 2005 where before this i already install SQL 2005 and uninstall it and delete some of the file inside the SQL folder, after that i reinstall the SQL 2005 and it get many error while installing.

Can some 1 guide me how to unintall it completely?

PS: im using Vista

View 2 Replies View Related

Pull Overlapping Fields

Apr 9, 2008

Hello,
How can I create a query that pulls all records for a given ID (road) where the distances (based on start & end fields) overlap?

Eg. RoadNm Start End
Road 1 0 500
Road 1 300 800
Road 2 0 500
Road 2 500 800

I need to write SQL that flags Road 1 as a road with overlapping sections (whereas Road 2 is fine).

Thanks!
Amber

View 3 Replies View Related

Completely New To SQL Server 2000

Oct 16, 2006

Hello, I have installed Enterprise edition. I used Client Network Utility to create a server. I went into Enterprise manager and tried to register this server I created and I got the following error:
Specified SQL Server not found

What should I do?

View 20 Replies View Related

Does SQL Work Completely In Memory

Feb 1, 2008

Assume you have a query SELECT Column1 from Table WHERE Column2 = 'x' Say you have a non-clustered index on Column2. The engine is going to load the non-clustered index into memory to search for that record then do a lookup to the clustered index to grab column one also but quickly becuase it knows the RowID.. Right?

Is that safe to assume that every table that is queried would need to be in memory? ie the buffer pool? So if I have a table that has 2 million records, any operation on that data requires the table to be in memory?

View 6 Replies View Related

Can I Have Replication Between Two Completely Different Schemas?

Feb 22, 2007

Hi SQL guys,

I have 2 different databases and an import tool that reads from one and fills the other one and then whenever we run it, it should synch the two databases and its kind of a heavy task. I was wondering if i can replace it with replication between these databases. I defined publisher and subscriber, but i cannot find anywhere that i can say which field in source maps to which field in destination.

Is it possible at all to have a replication between 2 databases with totally different schemas? If so, please let me know how.

Thanks,

Sina

View 4 Replies View Related

Uninstalling SQL 2005 Completely

Apr 18, 2006

hi all,

i have gone through the thread which had the same subject but still it didn't work out..

i have even removed SQL 2005 install bits using msicuu2.exe but still i can find SQL 2005 in my programs list in start menu....

Can anyone please let me know how i can remove SQL 2005 completely when it does not show up in Add/Remove programs and WindowsInstaller Cleanup Tool but i can still find it if i navigate to Start --> All programs --> Microsoft SQL Server 2005......

regards,

View 15 Replies View Related

How Can I Completely Delete A CE Table?

Aug 28, 2007

I have an application created with VS 2005 and VB 2005 using a Compact Edition Database. I created some tables that I no longer use or want. How can I permanently delete them from the database?

View 1 Replies View Related

Overlapping Images And Rectangles

May 7, 2008



Hey
I am trying to create a report where I want overlapping images and rectangles... but when I upload it to report manager it seems to push them all seperate??? How do I stop doinh this... it does print okay! Just looks wrong on screen?

Thanks

View 5 Replies View Related

DTS Packages Not Migrating Completely

Jun 28, 2007

Hi, I upgraded several of my SQL 2000 database to SQL 2005 databases. I'm in the process of migrating over the DTS packages over to SSIS packages. I'm using the DTSMigrationWizard utilty to do this migration. When I started testing the SSIS packages I've discovered that not all the steps were being excuted. So I've noticed on several of the packages not everything migrated over. Such as connections to oracle and some of the task as well did not migrate over. Is there a way to migrate the entire DTS package to SSIS or do I have to re-create the entire package from scratch or is there a better way to get the SQL 2000 DTS packages over to SQL 2005 and have them run successfully?







View 3 Replies View Related

How Do You Uninstall SQL Express Completely?

May 24, 2008

Hello Win XP Pro, SP3 ,.Net 1.1,2.0,3.5, ASP.Net 2.0.

I made the mistake of trying to install SQL Server 2005 Express Edition with Advanced Services as a requirement to install dashCommerce. That was a big mistake. It never installed and it screwed up my current install of SQL Server 2005 Express Edition.

I have been trying for two days now to get my SQL Server 2005 Express Edition back to normal. I can't run and test my programs in VS2005 that use SQL anymore and it's keeping me from getting my work done.

I tried uninstalling everything SQL using Add Remove Programs. Deleted all temp, SQL and unneeded files. Ran defrag. Restarted my computer. I did all that three times and still am unable to install SQL Server 2005 Express Edition.

On the existing components screen, i get the message "The following components that you chose to install are already installed on the machine. To view a report of available options and alternatives click on details."

It won't allow me to check any options and when i click next, it gives the error "None of the selected features can be installed or upgraded. Setup cannot proceed since no effective change is being made to the machine. To continue, click Back and then select features to install. To exit SQL Server Setup, click Cancel"

All i can do is cancel out of it.

Any help from anybody to figure out why i can't install SQL Express again would be gratefully appreciated.

This problem is keeping me from doing my work, it's frustrating. Is there a way to totally clean my machine of any SQL so i can get back to doing my job?

Thanks,
Tony

View 6 Replies View Related

Preventing Overlapping Data Entry

Apr 17, 2007

Hello Everyone,
 I have a web form that allows the user to select a time to reserve.  I am trying to make it so that when a user selects a date to schedule something (which i have working) a drop down list will fill with times that have not been reserved. 
The data is stored in two tables: tblCalendar and tblTime.  tblTime contains pkTimeID and times (which are all possible times to select from in half hour intervals). tblCalendar contains a few fields but timeID and date (which is in the format M/d/yyyy) are what I need to test against.  timeID is the foreign key of pkTimeID. 
Basically when the user selects the date, a function gets called that will run a SELECT statement to get the times available.  All of this works, I am able to fill the ddl with all times available no matter what the date is or what has already been reserved.  I want to check if a time has been already selected based on the date selected by the user and only allow times not selected to be listed.
 After acheiving this I would like to prevent the immediate time before and immediate time after from being displayed because each reserved time will last for one hour but the data is stored in half hour increments.
Any help/suggestions/links will be greatly appreciated.  If I need to provide anything else please let me know.
Thanks in advance,
Brian

View 3 Replies View Related

Completely Script SQL 2005 Database

Oct 18, 2006

Hi Everyone, what im looking for is a way or a freeware utility that will genereate a single SQL Script, for my entire db...

Just like phpMyAdmin does for MySQL...

it would need to script my tables, the data of those tables, and all my stored proc's.

Can SQL Server management studio do this? or does anyone know of a utility that will.

Thanks, Justin

View 5 Replies View Related

Comparing Two Date Periods For Overlapping

Nov 9, 2006

hi guys,

i have a booking table which has the following columns...

booking
-------------------------------------------
dCheckin (format 11/9/2006 12:00:00 AM)
dCheckout (format 11/11/2006 12:00:00 AM)

when a new booking is entered, we want to make sure that the period entered does not conflict with an existing record.

not sure how to go about building the query required. any help would be greatly appreciated.

mike

View 4 Replies View Related

T-SQL (SS2K8) :: Merging Non Overlapping Timedates

Sep 17, 2014

Using SQL 2008 R2 and stuck on this.

I have several sets of timedate ranges and I need to merge the ranges where there is no overlap with the jobs on resource1. In my example data, I want all jobs from ResourceID 1 and those jobs from all other resources where they do not overlap with EXISTING jobs on resource 1 (i.e. imagine I'm trying to select candidates from other resources to fill ResourceID 1 with continuous jobs)

Below is some sample data, my failed attempt and expected results. I managed to excluded everything that should be excluded except job 10

-- Need to select all other jobs from all other resources that can be merged into resource 1 where there is no overlap with existing jobs in resource 1 only

CREATE TABLE #Jobs
(
resourceID INT
,JobNo INT
,StartTime SMALLDATETIME
,EndTime SMALLDATETIME
,ShouldBeOmitted BIT

[Code] ....

View 8 Replies View Related

Completely Uninstall Sql Server 2005

Oct 9, 2007

i need help for completely removing sql server 2005 from my computer,in order to reinstall it again.

please help me

View 3 Replies View Related

Completely Remove Sql Server 2005

Oct 9, 2007

I need help for completely removing sql server 2005 from my computer.
I have tried unintalling it through Add/Remove programs,but when i try to reinstall it this message appears :
"Some components of this edition of SQL Server are not supported on this operating system. For details, see 'Hardware and Software Requirements for Installing SQL Server 2005' in Microsoft SQL Server Books Online."
I think that there is something that is not completely removed from the first installation.

View 15 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved