I lost several of the saved, working SQL scripts that we currently use when I was migrated to a new machine. One of the most valuable was one that I was helped with by a super Expert on Experts Exchange. Problem is now that I had to make a couple of changes and I can't get it to work any longer.
I have two tables in SQL: A--Sales Comparison and B-Wholereplace
The two tables are joined by md_retailer (Table A) to custID (Table B). In Table A we currently have a field called wholesalerID (Table A) that needs to be updated from wholeID (table B). The main trick is that I only want to change records where the wholesalerID (table A) starts with "120".
Here is the code that is broken.
;WITH tfr AS (
WHERE WholesaleID = '120-MW'
MERGE INTO [NYP-RetailDataSQL].dbo.[Sales-Comparison0830A]
USING tfr ON md_Retailer = [Cust Id]
WHEN MATCHED THEN UPDATE
SET WholesaleID = WHOLEID;
I am sure that I have things twisted and backwards and that is why I desperately need assistance. My knowledge of SQL is beginner level at best so please be as simple as possible.
Thanks so much