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 |
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2011-09-30 : 10:16:22
|
| Is it possible to simplify the following two updates by placing them into one update ?Thanks update y set y.Field1 = ipc.Yld from tblY as y inner join CCcy as cc on (y.Ccy = cc.Ccy and y.ICode = cc.ICode) inner join @IPC as ipc on (cc.Ccy = ipc.Ccy and cc.Name = ipc.Country) where ipc.LngDur = '0-x' update y set y.Field2 = ipc.Yld from tblY as y inner join CCcy as cc on (y.Ccy = cc.Ccy and y.ICode = cc.ICode) inner join @IPC as ipc on (cc.Ccy = ipc.Ccy and cc.Name = ipc.Country) where ipc.LngDur = '5-9' |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-30 : 10:59:10
|
| [code]updateysety.Field1 = case when ipc.LngDur = '0-x' then ipc.Yld else y.Field1 end,y.Field2 = case when ipc.LngDur = '5-9' then ipc.Yld else y.Field2 end fromtblY as y inner join CCcy as cc on (y.Ccy = cc.Ccy and y.ICode = cc.ICode)inner join @IPC as ipcon (cc.Ccy = ipc.Ccy and cc.Name = ipc.Country)whereipc.LngDur in ( '0-x','5-9')[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-09-30 : 10:59:49
|
[code]update yset y.Field1 = case when ipc.LngDur = '0-x' then ipc.Yld else y.Field1 end, y.Field2 = case when ipc.LngDur = '5-9' then ipc.Yld else y.Field2 endfrom tblY as y inner join CCcy as cc on (y.Ccy = cc.Ccy and y.ICode = cc.ICode) inner join @IPC as ipc on (cc.Ccy = ipc.Ccy and cc.Name = ipc.Country)where ipc.LngDur in ( '0-x' , '5-9')[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-09-30 : 11:00:35
|
 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|