Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2008-04-08 : 06:56:46
|
| I am trying to write the following using either an if/else or case, any help would be aprreciated.Set the OPPORTUNITY.account_manager_override to false when the COMPANY.account_manager = 'xxx'. In all other cases, set the OPPORTUNITY.account_manager_override to true. Sounds simple enough....This may help:select opportunity_name, o.account_manager_id opp_manager, o.account_manager_override opp_override,co.account_manager_id company_manager, co.account_manager_override company_overridefrom opportunity oinner join company co on co.company_id = o.company_idwhere co.account_manager_id = xxx |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-04-08 : 07:00:23
|
| Use a case. |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2008-04-08 : 07:21:25
|
| I suspected case, any coding samples would be appreciated. |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-08 : 07:35:33
|
| [code]Case when COMPANY.account_manager = 'xxx' then 0 else 1 end as account_manager_override[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2008-04-08 : 07:53:58
|
| Great, ended up with somthing like this....UPDATE o SET o.account_manager_override = CASE WHEN (co.account_manager_id = 1234) THEN 0 ELSE 1 ENDfrom opportunity o inner join company co on co.company_id = o.company_idwhere opportunity_name = 'Test' |
 |
|
|
|
|
|