vendredi 19 août 2016

CASE with IS NULL not working

I want to give column some value if the value is NULL I tried like below

insert into inward_doc_tracking_trl 
    (Mkey,Entry_Sr_No,N_UserMkey,N_Department,CStatus_Flag,Remarks,     
    CUser_Id,
    U_Datetime,NStatus_Flag,Delete_Flag, 
    CDept_Id,
    Ref_Mkey,No_Of_Days,Approved_Amount,Chq_No,Chq_dated,Chq_Bank,Chq_Amount,
    Vendor_MKey,Vendor_Comp_Mkey,Project_Mkey,Program_mkey,Payment_MKey,Due_Date,Updated_Remarks,Updated_Bill_no,
    Updated_Bill_Date,Updated_Bill_Amt,Party_Name,Acc_mkey,
    TotalDeductions,Broker_Mkey,Customer_Mkey,Payable_Amt,Balance_Amt)

     values (@inv_trl_mkey,@entry_sr_no,@Nuser_mkey,@n_department,@nstatus_flag2,@remarks,               
        CASE WHEN (@cuserid IS NULL) THEN 'YES' ELSE 'NO' END AS @cuserid,
    @u_datetime,@nstatus_flag,@delete_flag,     
        CASE WHEN (@cdept_id IS NULL) THEN 'YES' ELSE 'NO' END AS @cdept_id,
    @inv_hdr_mkey,@No_Of_Days,
     @Approved_Amount,@Chq_No,@Chq_dated,
     @Chq_Bank,@Chq_Amount,@Vendor_MKey,@Vendor_Comp_Mkey,@Project_Mkey,@Program_mkey,@Payment_MKey,@Due_Date  
    ,@Updated_Remarks,@Updated_Bill_no,@Updated_Bill_Date,@Updated_Bill_Amt,@Party_Name,
    @Acc_mkey,@TotalDeductions,@Broker_Mkey,@Customer_Mkey,@Payable_Amt,@Balance_Amt)  

but getting error as

Incorrect syntax near the keyword 'AS'.

Aucun commentaire:

Enregistrer un commentaire