Solved

field differences

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Updating a field based from a if exist.... 2 46
Search query matching words 20 49
Question about Common Table Expressions 3 45
SQL Query 20 25
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

710 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