We help IT Professionals succeed at work.
Get Started

SQL Update using multiple WHERE conditions

165 Views
Last Modified: 2015-04-29
I have a SQL 2008 R2 database with 2 fields in it, MaterialNo and SalesPerson. Lets say the database has 5,000 records in it. I was just informed via an Excel spreadsheet that 300 of these 5,000 material numbers have the wrong SalesPerson assigned. The spreadsheet lists all the 300 material numbers and the correct SalesPerson. Normally I would just use a simple

UPDATE table
SET SalesPerson='John Doe'
 WHERE MaterialNo='12345'

But I do not want to do 300 numbers one at a time like this. What would the process or syntax be to do something like this:

UPDATE table
SET SalesPerson='John Doe'
 WHERE MaterialNo='MY LIST OF 300 MATERIAL NUMBERS'

I am a SQL novice so don't assume anything :-)
thx experts...
Bob R
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 15 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE