Hello.
I'm quite new to SQL so please bear with me.
I have a db with two tables. Among other columns they both have [Supplier Code] and ManufactureMarking. They also both have an NVARCHAR column called Description. There's no relationship set up between the two.
They both contain price lists from suppliers. One contains the raw data direct from the supplier and the other contains a copy of that with some additional data entered by an operator via an upstream app (they are called dbo.TempPriceBook and dbo.PriceBook
respectively)
When a record is copied into the latter table (via an external API connection) the supplied data from the Description column from dbo.TempPriceBook goes into a column in dbo.PriceBook called SupplierDescription and the Description column in dbo.PriceBook is
used to store a customised description that's entered by the operator on our side.
The point of the exercise is that when a supplier sends a new price list (which is usually a full list, not just changed items), it goes into dbo.TempPriceBook and I want to use that to look through dbo.PriceBook and find any matching rows where the Supplier
Code and ManufactureMarking are the same but the description from the supplier has changed (regardless of how the operator has customised the description), and show the results with all columns from the PriceBook table, including the original supplier description,
the customised one and the new supplier description from TempPriceBook.
I have played around with INTERSECT and EXCEPT a bit.
select [Supplier Code], ManufactureMarking, SupplierDescription from dbo.TempPriceBook except select [Supplier Code], ManufactureMarking, Description from dbo.PriceBookThis query gives me a result where the description has been updated by the supplier (in TempPriceBook) and new items in TempPriceBook that don't exist at all in PriceBook, which I do want to see. Is this the right way to start?
Then is a UNION the approach to take to get the rest of the columns? If so, how would I combine them into a query?
I have full control over the database and the upstream application and I can change the column names, drop the tables, re-create them, whatever. It's not a production system yet.
My goal is to eventually create a view that I can use in the app.
Many thanks in advance, and sorry for the long-winded post!
Will.