473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comparing Tables

Hello,

I have read many articles about comparing tables, like - loops, delete
queries, appending to temp table with index etc

Problem: 2 tables T1 & T2. Data is suppposed to be the same in both
tables but i need to check that this is so. (Maybe a user deleted a
row in one table only or changed a value in a field!). The tables have
no unique index.

Question: How do I compare the tables to resolve the above problem?

Answer: Because (in my particular case) I only have 4 fields in T1 and
T2, I concatenated the the 4 fields into 1 field in both tables and
then "Found unmatched records" between the 2 tables i.e. the 2 tables
represented now as T1a and T2a each with 1 field.

I'd appreciate anyones comments, suggestions or cleverness to resolve
the problem as described and offer a more general solution.

Thank you for your time....
Nov 13 '05 #1
4 4164
osmethod wrote:
Hello,

I have read many articles about comparing tables, like - loops, delete
queries, appending to temp table with index etc

Problem: 2 tables T1 & T2. Data is suppposed to be the same in both
tables but i need to check that this is so. (Maybe a user deleted a
row in one table only or changed a value in a field!). The tables have
no unique index.

Question: How do I compare the tables to resolve the above problem?

Answer: Because (in my particular case) I only have 4 fields in T1 and
T2, I concatenated the the 4 fields into 1 field in both tables and
then "Found unmatched records" between the 2 tables i.e. the 2 tables
represented now as T1a and T2a each with 1 field.

I'd appreciate anyones comments, suggestions or cleverness to resolve
the problem as described and offer a more general solution.

Thank you for your time....


Why do you have two tables the same? Is there a point?
Nov 13 '05 #2
Hello Trevor,

Yes there is a need....

I get a file on week 1 of each month of test results.
I then get a second file on week 2 of the same month which has the
accumulated results for week 1 and week 2.

The week 1 results in the weeks 2 file could have changed, e.g. a test
value in a field or maybe they omitted a test result which was
originally in weeks 1 file.

Because results are sent to suppliers at the end of each week, I can't
so well send out the accumulative results if week 1 of weeks 2 file is
different than the first weeks 1 file.

I have a results table and a results_temp table.
1st weeks file is OK to import to the results table after some checking.
2nd weeks results file is imported into the "results_te mp table",
compared against the "results" table and I then need to show the user
the differences so she can make a decision which is correct.

I hope this explains why...
P.S. Your website has been of great help on the past while.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
osmethod wrote:
Hello,

I have read many articles about comparing tables, like - loops, delete
queries, appending to temp table with index etc

Problem: 2 tables T1 & T2. Data is suppposed to be the same in both
tables but i need to check that this is so. (Maybe a user deleted a
row in one table only or changed a value in a field!). The tables have
no unique index.

Question: How do I compare the tables to resolve the above problem?

Answer: Because (in my particular case) I only have 4 fields in T1 and
T2, I concatenated the the 4 fields into 1 field in both tables and
then "Found unmatched records" between the 2 tables i.e. the 2 tables
represented now as T1a and T2a each with 1 field.

I'd appreciate anyones comments, suggestions or cleverness to resolve
the problem as described and offer a more general solution.

Thank you for your time....


Pretty tough if you have no PK, a find non matched query is a good way
to go about it. What if all fields change for a particular record or
that only one field has changed or looked like it changed but is
supposed to be in fact a different record?

Do the tables come in each week with the same number of records?
Nov 13 '05 #4
> Pretty tough if you have no PK, a find non matched query is a good way
to go about it. What if all fields change for a particular record or
that only one field has changed or looked like it changed but is
supposed to be in fact a different record?

Do the tables come in each week with the same number of records?

An Example:
Week 1 File
ID Date Test Result
1 04/08/04 Fat 2.53
1 04/08/04 Pro 1.57
1 05/08/04 Cbh 0.67

Week 2 File
ID Date Test Result
1 04/08/04 Fat 2.53 Same as line 1 above
1 03/08/04 Pro 1.57 Date changed on this one
Line 3 not included at all..!

I concatenated the fields ID,Date,TestRes ult e.g.
Line 1 above then becomes - 104/08/04Fat2.53

Now if i "Find unmatched" Line1 will not show because it is the same
in both files.

Lines 2 form both tables will show as the date was modified.
Line 3 on 1st table will show because its equivalent is missing in 2nd
table.

I then un-parse the lines and show them to the user. She has to decide
what to do. I use the transaction methods because its an all or
nothing untill a decision is made, which, is right.
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

41
3963
by: Odd-R. | last post by:
I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and Y contains all the elements that are B but not in A. Z will then have the elements that are in both A and B. One way of doing this is of course to iterate throug the lists and compare each of the element, but is there a more efficient way? ...
0
1691
by: laxmiuk | last post by:
I've original version of a table called PMM (Product Material Master). Thro' a web interface, user can change that table contents. Once changed, i need to raise an ECN (Engineering CHange Note) specifying what changes happened to original PMM table whether rows are deleted, new rows are added or existing rows are modified etc. I've both old and new version of PMM tables. The difference between two PMM tables are captured in a third table...
2
1715
by: windandwaves | last post by:
Hi Guys I want to find out if two tables are identical (e.g. same fields, same indexes, etc....). Not the data, but the table structure itself. Is there a smart way to do that? Cheers
1
2868
by: Reg Rat | last post by:
Hello all, I'm led to believe that the .Net framework offers intelligent string comparison such that é follows e in an alphabetic sort rather than appearing after z, for example. Does this mean that there is a mechanism for comparing strings that may or may not have accents and having them shown as identical (e.g. comparing Herve with Hèrvé would show a match). Ideally, this should be culture neutral as I will not have knowledge of which...
19
2982
by: Will Lastname | last post by:
In one of the applications that I'm working on I have 2 sets of functions that build different datasets. Imagine 4 columns in a datagrid. Inside those 4 columns I have nested datalists. Two of the datalists' datasources point to database A and the other two point to database B. This effect allows the client to perform a side-by-side comparison of the same product so that records can be updated accordingly. It's easy enough to scroll down...
21
2341
by: Kristaps | last post by:
Hi everyone! I have some questions, maybe someone can help me... I write script for table comparing, but it works wery slovly. There is the script, can anyone give some tip how can I make this process faster and if it is possible in VB. The idea is to compare two tables and if there is some distinction, then is written in third table. Some tables contains more than 200 000 rows and each row contain approximatelly 30 parameeters (columns)....
3
2043
by: hasnain | last post by:
Dear All, I want to compare two tables. Both of the tables have same fields but their location in terms of columns can be different. My target is to get those fields only whose values are found different on comparing. Regards Hasnain
5
1862
by: Franck | last post by:
how come unchanged always true even if data changed This code come from my saving button: ============================================ DataSet ds1 = new DataSet(); DataSet ds2 = new DataSet(); DataSet ds3 = new DataSet(); //Static Dataset which contain values when my form load
4
6406
by: gillianbrooks91 | last post by:
Forgive me for asking this question, I've trawled through nearly every available post on this subject that I can find for a few weeks now but nothing quite points me in the right direction. I'm quite new to trying to mess around with VB and ADO within MS Access and have realised the steep learning curve I have, but, I want to try and solve this problem quickly and was wondering if anyone would help me out?? I want to be able to...
0
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9470
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4033
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.