如何在SSIS的更新查询中编写case语句

时间:2022-10-01 15:33:32

how to write below update query in SSIS:

如何在SSIS中编写以下更新查询:

 declare @janflag as varchar(56) 
 set @janflag ='y' 
 declare @febflag as varchar(56) 
 set @febflag ='y'/[ SELECT TOP 1 febfl FROM saupdate ]   
      * saupdate table in the control flow.
 UPDATE  sacustomer 
 SET  salesamt1 = CASE WHEN (@janflag='y') THEN ? ELSE salesamt1 END ,
 costamt1 = CASE WHEN (@janflag='y') THEN ? ELSE costamt1 END ,
 qtysold1 = CASE WHEN (@janflag='y') THEN ? ELSE qtysold1 END ,

 salesamt2 = CASE WHEN (@febflag ='y') THEN ? ELSE salesamt1 END ,
 costamt2 = CASE WHEN (@febflag ='y') THEN ? ELSE costamt1 END ,
 qtysold2 = CASE WHEN (@febflag ='y') THEN ? ELSE qtysold1 END 

 where cono=? 
 and yr=?    
 and divno= ? 
 and whse= ?
 and custno= ?

Getting error while writing,Please suggest..

写作时出错,请建议……

1 个解决方案

#1


0  

Possible this be helpful for you -

可能这对你有帮助

DECLARE @janflag VARCHAR(56) 
SELECT @janflag = 'y' 

UPDATE dbo.sacustomer
SET     
      salesamt1 = 1
    , costamt1 = 1
    , qtysold1 = 1
WHERE cono = '10'
    AND custno = '900'
    AND @janflag = 'y'

#1


0  

Possible this be helpful for you -

可能这对你有帮助

DECLARE @janflag VARCHAR(56) 
SELECT @janflag = 'y' 

UPDATE dbo.sacustomer
SET     
      salesamt1 = 1
    , costamt1 = 1
    , qtysold1 = 1
WHERE cono = '10'
    AND custno = '900'
    AND @janflag = 'y'