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 |
|
nidabp
Starting Member
15 Posts |
Posted - 2011-04-29 : 06:08:41
|
| Hi,Merge TableA as Ausing((SELECT query)) as BON A.x = B.xWhen Matched and ReportPeriod = 1 Then UpdateSet JanMet = 1 and JanMetALT = 1When Matched and ReportPeriod = 2 Then UpdateSet FebMet = 1 and FebMetAlt = 1When Matched and ReportPeriod = 3 Then UpdateSet MarMet = 1 and FebMetAlt = 1...Is there a way to have conditional updates and inserts to different columnsThanx |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-29 : 08:18:29
|
| When Matched then updatesetJanMet = case when ReportPeriod = 1 then 1 else JanMet end ,JanMetALT = case when ReportPeriod = 1 then 1 else JanMetALT end ,FebMet = case when ReportPeriod = 2 then 1 else FebMet end ,FebMetALT = case when ReportPeriod = 2 then 1 else FebMetALT end ,...==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
nidabp
Starting Member
15 Posts |
Posted - 2011-05-02 : 04:22:51
|
| Thank you...It fixed the issue.. |
 |
|
|
|
|
|