473,385 Members | 1,890 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,385 software developers and data experts.

Finding Changed Records

I need to create a table that would be the result set of a comparison
between table a and table b? Table a and b first 2 fields will always be
the same (CustomerName and CustomerNumber). But if the Address1 field
changes in table a, I would like to throw that whole row into my
comparison table. Almost like a Select Into with a sub query that would
include a WHERE TableA.field <> TableB.field. I would need to do this
comparison for about 8 fields. Help appreciated for my syntax is pretty
bad. Thanks.

Steve

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
1 1672
Hi

Assuming that the first two fields are a primary key then you need to join
on the primary keys and difference the other columns:

e.g

INSERT INTO DIFFERENCES ( Col1, Col2 , Col3, Col4, Col5, COl6, Col7, Col8 )
SELECT A.Col1, A.Col2, A.Col3, A.Col4
FROM TableA A JOIN TableB B JOIN A.Col1 = B.Col1AND A.Col2 = B.Col2
WHERE A.COl3 <> B.Col3
OR A.Col4 <> B.Col4
OR A.Col5 <> B.Col5
OR A.Col6 <> B.Col6
OR A.Col7 <> B.Col7
OR A.Col8 <> B.Col8

John

"Steve Bishop" <st****@viper.com> wrote in message
news:40***********************@news.frii.net...
I need to create a table that would be the result set of a comparison
between table a and table b? Table a and b first 2 fields will always be
the same (CustomerName and CustomerNumber). But if the Address1 field
changes in table a, I would like to throw that whole row into my
comparison table. Almost like a Select Into with a sub query that would
include a WHERE TableA.field <> TableB.field. I would need to do this
comparison for about 8 fields. Help appreciated for my syntax is pretty
bad. Thanks.

Steve

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #2

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

Similar topics

4
by: Aaron W. West | last post by:
Timings... sometimes there are almost too many ways to do the same thing. The only significant findings I see from all the below timings is: 1) Integer math is generally fastest, naturally....
5
by: sdowney717 | last post by:
Is there a way to construct a query to select for whole words only? select id from bookdata where titles like '%Test%' gets everything with test somewhere in the field. So you could get records...
2
by: Antitax | last post by:
I have a database with more than 800 adress records Some of the are similar because some letters in the street adress for example are not identical, altough they point to the same adress. Does...
3
by: Kyle Keller | last post by:
I created a database which my company has used for over 2 years at now over 30 locations. Just today, one of the locations called and was having problems with their program. The database is A97...
3
by: DavidB | last post by:
New to .net....sorry if this seems repetitive I have a dataset ordered by date (SQLDataAdapter SelectCommand uses Order By) and want to find a record by a UniqueID(Identity Column). Then I want...
2
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. ...
3
by: Gary Greenwald | last post by:
I want to identify records that have changed since the last export. Is there a record property or some method to identify when it was last changed? I am using Access97 and 2003. Thanks
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
1
by: Deepmala26 | last post by:
Hi, I m doing a project in VB.NET. I've created form and database connectivity is done. I've displayed data in Datagrid through which user can sort and find records. for finding...
6
by: MyWaterloo | last post by:
''''''''''''''''''''''''''''''''''''''''''' ' The AfterUpdate event procedure used in ' ' the Find Customer combo box search. ' ''''''''''''''''''''''''''''''''''''''''''' 'Moves to...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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,...

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.