473,378 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 4118
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_temp 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,TestResult 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
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...
0
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)...
2
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
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...
19
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...
21
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...
3
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...
5
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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.