Solved

field differences

Posted on 2010-11-24
1
305 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 75

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL: launch actions one before the other 10 24
ServiceCenter IR Query Expressions 1 41
Mysql Left Join Case 10 70
Microsoft Access Delete all Records from table but Max 2 24
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 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