troubleshooting Question

Merge statement with condition

Avatar of spudmcc
spudmccFlag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2008
12 Comments1 Solution402 ViewsLast Modified:
Hi Experts

I have a statement that was created that finds and replaces data from one table to another.  This works quite well and does the trick.  We now need to add condition.  We want to do the update and add that it only be a specific id that is updated.  

The code that we currently use now is:

MERGE INTO [NYP-RetailDataSQL].dbo.[Sales-Comparison0830A]
   USING [NYP-RetailDataSQL].dbo.wholereplace
      ON md_Retailer = [Cust Id]
      SET WholesaleID = WHOLEID;

What I need to add is that I only want it to be when the WHOLEID = 120-MW.  

Any help would be greatly appreciated as always.  

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros