Solved

field differences

Posted on 2010-11-24
1
291 Views
Last Modified: 2012-05-10
I have two tables one that has new data monthly and the other a back up of it. I have renamed last months, how do i create a query that will tell me if any data in any field changed  value?

so [currentmonth].[field1] =[lastmonthsbackup].[field1] no change
 [currentmonth].[field2]<>[lastmonthsbackup].[field2] data changed so row returned

the two tables are obviously identicle in structure.
SELECT SMMT.[DVLA CODE], SMMT.[MVRIS MAKE CODE], SMMT.[MVRIS MODEL CODE], SMMT.[MVRIS CODE], SMMT.[VEHICLE CATEGORY CODE], SMMT.[VEHICLE CATEGORY DESCRIPTION], SMMT.[INTRO DATE], SMMT.MARQUE, SMMT.[MODEL RANGE], SMMT.[RANGE SERIES], SMMT.[MODEL YEAR], SMMT.VARIANT, SMMT.CC, SMMT.[NOM CC], SMMT.DOORS, SMMT.[BODY TYPE], SMMT.TRANSMISSION, SMMT.FUEL, SMMT.ASPIRATION, SMMT.[COUNTRY OF ORIGIN], SMMT.[DRIVE TYPE], SMMT.[ENGINE LOCATION], SMMT.[DRIVING AXLE], SMMT.[FORWARD GEARS], SMMT.SEATS, SMMT.[ENGINE MAKE], SMMT.[ENGINE MODEL], SMMT.[ENGINE CONFIGURATION], SMMT.[FUEL DELIVERY], SMMT.BORE, SMMT.STROKE, SMMT.[NO CYLINDERS], SMMT.[VALVES PER CYLINDER], SMMT.[VALVE GEAR], SMMT.[MAIN FUEL], SMMT.[POWER KW], SMMT.[MKT BHP], SMMT.[CALC BHP], SMMT.[POWER RPM], SMMT.[TORQUE NM], SMMT.[TORQUE LBFT], SMMT.[TORQUE RPM], SMMT.[MAX SPEED MPH], SMMT.[MAX SPD KPH], SMMT.[ACCELERATION 0-100 KPH], SMMT.[URBAN COLD MPG], SMMT.[URBAN COLD LITRE / 100 KMS], SMMT.[EXTRA URBAN MPG], SMMT.[EXTRA URBAN LITRE / 100 KMS], SMMT.[COMBINED MPG], SMMT.[COMBINED LITRE / 100 KMS], SMMT.CO2, SMMT.LENGTH, SMMT.WIDTH, SMMT.HEIGHT, SMMT.WHEELBASE, SMMT.[MARKET SEGMENT], SMMT.GVW, SMMT.PAYLOAD, SMMT.[UNLADEN WEIGHT], SMMT.[KERB WEIGHT MIN], SMMT.[KERB WEIGHT MAX], SMMT.[EURO STATUS], SMMT.[INSURANCE GROUP], SMMT.[Ref ID], SMMT.MARKET, SMMT.[TERMINATION DATE], SMMT.VehicleCountByMvris, SMMT.Notes, SMMT.[VIN stem], SMMT.RelatedMvrisCode, SMMT.[CAB TYPE], SMMT.[LOADSPACE LENGTH], SMMT.[VAN ROOF CONFIG], SMMT.[WHEELBASE TYPE], SMMT.NCAP_Adult, SMMT.NCAP_Child, SMMT.NCAP_Pedestrian, SMMT.NCAP_SafetyAssist, SMMT.NCAP_Overall, SMMT.Checked, SMMT.CountSinceRefresh, SMMT.DPF, SMMT.CalcNomCC, SMMT.[MCRIS Make Code], SMMT.[MCRIS Model Code]
FROM SMMT INNER JOIN SMMT_Previous ON SMMT.[MVRIS CODE] = SMMT_Previous.[MVRIS CODE];

Open in new window

0
Comment
Question by:PeterBaileyUk
1 Comment
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 34205141
Add a WHERE condition comparing all the fields which you care about. Check that they are not equal to each other and OR each set of fields together. Pseudocode:
WHERE t1.f1 <> t2.f1 OR t1.f2 <> t2.f2 OR t1.f3 <> t2.f3

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now