title: Switch CASE in stored procedure in SQL
body: <p>getting error in switch case</p>
  
  <pre><code>SELECT CASE @PurchaseId
        WHEN 1 THEN INSERT into tblPurchaseInMstr(DocNo,DocType,DocDate,PurchaseDate,SalesNodeId,SalesNodeType,FYID,LoginIDIns, TimestampIns,StatusId,InvTotPurchValue,InvTotPurchWDisc,InvNetAmt,DocSourceNodeId,DocSourceNodeType,InvTotalCGSTAmt,InvTotalSGSTAmt,InvTotalIGSTAmt)
   values(@DocNo,@DocType,@DocDate,@PurchaseDate,@SalesNodeId,@SalesNodeType,@FYID,@LoginID, GETDATE(),@StatusId,@InvTotPurchValue,@InvTotPurchWDisc,@InvNetAmt,@DocSourceNodeId,@DocSourceNodeType,@InvTotalCGSTAmt,@InvTotalSGSTAmt,@InvTotalIGSTAmt)
  
  WHEN @PurchaseId 2 THEN UPDATE tblPurchaseInMstr set DocNo=@DocNo DocType=@DocType,DocDate=@DocDate,PurchaseDate=@PurchaseDate,SalesNodeId=@SalesNodeId,SalesNodeType=@SalesNodeType,FYID=@FYID,LoginIDUpd=@LoginId,TimestampUpd=GETDATE(),StatusId=@StatusId,InvTotPurchValue=@InvTotPurchValue,InvTotPurchWDisc=@InvTotPurchWDisc,InvNetAmt=@InvNetAmt,DocSourceNodeId=@DocSourceNodeId,DocSourceNodeType=@DocSourceNodeType,InvTotalCGSTAmt=@InvTotalCGSTAmt,InvTotalSGSTAmt=@InvTotalSGSTAmt,InvTotalIGSTAmt=@InvTotalIGSTAmt where PurchaseId=@PurchaseId
  
   WHEN 3 THEN DELETE tblPurchaseInMstr
  
   END AS Purchaseid  from tblPurchaseInMstr
  
  END
  
  GO
  </code></pre>