I want to use a CASE
statement instead of an IF...ELSE
statement but the CASE
statement give me issues. Please check the stored procedure below. It is complaining about a syntax error next to UPDATE
.
ALTER PROCEDURE [dbo].[UpdateRFQStatusDashboardCountForAllUsers]
(
@UserID [nvarchar](128)='6aab7553-72ef-46d8-b831-5c8d5e269cb3',
@ColumnName [nvarchar](50)='Close'
)
AS
BEGIN
SELECT
CASE @ColumnName
WHEN 'New' THEN
UPDATE [dbo].[RFQStatusDashboardCountForAllUsers]
SET New = New + 1
WHERE [UserID] = @UserID
WHEN 'Close' THEN
UPDATE [dbo].[RFQStatusDashboardCountForAllUsers]
SET [Open] = [Open] - 1, Closed = Closed + 1
WHERE [UserID] = @UserID;
END CASE
END