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.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 different column updates in merge

Author  Topic 

nidabp
Starting Member

15 Posts

Posted - 2011-04-29 : 06:06:44
Hi,

Merge TableA as A
using(
(SELECT query)) as B
ON A.x = B.x
When Matched and ReportPeriod = 1 Then Update
Set JanMet = 1 and JanMetALT = 1
When Matched and ReportPeriod = 2 Then Update
Set FebMet = 1 and FebMetAlt = 1
When Matched and ReportPeriod = 3 Then Update
Set MarMet = 1 and FebMetAlt = 1
...

Is there a way to have conditional updates and inserts to different columns

Thanx
   

- Advertisement -