HASH/Compare

Should be a simple question but I've never done it before and would love a little help getting started.  I have a demographic table with about 30 fields.  On a daily basis, I get a new file with potentially updated data.  Whats the simpliest way to do a comparison to see if any of the 30 field have changed?  I know I could do a series of WHERE newtable.field1<>existingtables.field1 but that has to be an easier way.

suggestions?

Thanks in advance!!
gmastervAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lwadwellCommented:
assuming all of the columns are in the same order in the existing and new tables ... try:

SELECT *
FROM newtable
MINUS
SELECT *
FROM existingtable
0
gmastervAuthor Commented:
they willl/can be exactly the same but I forgot to mention, what I want to do is compare it by account number (primary key in both tables) and see if any other field (address, city, st, zip, phone, etc) has changed.  If so, I just need to know what accounts have updated records.  Does this solution still work for that?  how would I write the join statement if so?  Thanks and my apologies for the lack of detail in my original question.
0
baretreeCommented:
being using MS SQL then you need to use EXCEPT instead since MiNUS is an Oracle statement
you can also use the NOT iN but EXCEPT is "newer"...


0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

gmastervAuthor Commented:
thank you, can you help me with the join statement?  will that work?
0
baretreeCommented:
just like lwadwell showed

SELECT  *
FROM     newTable
EXCEPT
SELECT  *
FROM     existingTable

you can insert the result into a temp table with same structure like # or @ tables

create table #tempTable (accountNumber type, address type, city type, etc )

insert into #tempTable
SELECT  *
FROM     newTable
EXCEPT
SELECT  *
FROM     existingTable

select accountNumber from #tempTable

drop table #tempTable

you can use a @ table like

declare  @tempTable table (accountNumber type, address type, city type, etc )

and avoid the "drop table" statement :)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy Hengel [angelIII / a3]Billing EngineerCommented:
suggestion would indeed to compare the hashed value (on all the data fields), which on the existing table could be a computed field ...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.