troubleshooting Question

MSSQL - Stored Procedure Error - Incorrect syntax near the keyword 'CASE'.

Avatar of Cyber-Drugs
Cyber-DrugsFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL Server
6 Comments1 Solution3242 ViewsLast Modified:
Hi guys 'n gals,

I have a problem with my CASE statement in my stored procedure, could somebody help me please?

My error:

Incorrect syntax near the keyword 'CASE'.
Incorrect syntax near the keyword 'END'.

My stored procedure:

CREATE PROCEDURE [sp_Test]
@column varchar(32),
@value varchar(64)
AS
BEGIN
CASE @column
WHEN 'tmp'
THEN DELETE FROM tblTemp WHERE UID=@value
END
END


Any idea on what I need to change?


Cheers!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros