Solved

Update Multiple Records with Array of Values

Posted on 2010-11-28
3
237 Views
Last Modified: 2012-08-13
Hi,

I found the update query structure on another post, and wanted to confirm this syntax will work.  I am expecting to only update the field DESCR for 3 records in the example given.   Does this look ok?



UPDATE IM_ITEM

SET DESCR =

CASE  ITEM_NO
               
                WHEN '1000029707' THEN 'APPLES CUYAMA'
            WHEN '1000007698' THEN 'APPLES GINGR GOLD ORGANIC'
            WHEN '1000007701' THEN 'APPLES GRNNY SMITH ORG'
 END

WHERE ITEM_NO IN ( '1000029707' , '1000007698' , '1000007701')
0
Comment
Question by:AD1080
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34224413
The syntax seems to be right. Any error with it ?

Raj
0
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 50 total points
ID: 34224421
'CASE' can be used as conditional. In your query, when ITEM_NO column have the value '1000029707', it will update DESCR column with  'APPLES CUYAMA' and so on

Raj
0
 

Author Closing Comment

by:AD1080
ID: 34224429
Hi,

No error.  Thanks for taking the time to confirm.  Just wanted to be 100% before updating a lot of records using this approach.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now