Solved

Is there any way to run a update with Case?

Posted on 2012-03-15
2
161 Views
Last Modified: 2012-03-15
Hello Guys,

I have an update script:

update product set price_sell = 123.45 where code=45

Open in new window


the problem is that I need to create a script with price_sell diferent when I am in a determined table, for example:

update product set price_sell = case database='viadiesel' then 123.45 else 187.74 end if where code=45

Open in new window


how can I do that? Is it possible?

thanks
Alexandre
0
Comment
Question by:hidrau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 37725084
yep, you just missed the WHEN:

update product set price_sell = case when database='viadiesel' then 123.45 else 187.74 end  where code=45
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 37725119
thanks
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In this article I will describe the Copy Database Wizard 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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

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