Solved

field differences

Posted on 2010-11-24
1
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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.…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

617 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