Solved

Update Multiple Records with Array of Values

Posted on 2010-11-28
3
236 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
Comment Utility
The syntax seems to be right. Any error with it ?

Raj
0
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 50 total points
Comment Utility
'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
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

11 Experts available now in Live!

Get 1:1 Help Now