July 6, 2007 at 12:19 am
Dear All,
I am using Sql server 2005
Let me explain you scenario.
I would like to know Is it possible to use switch case(like we do in C#) in stored procedure.if not what if alternative of that. Because based on input parameter I would like to perform different action
Please guide me or give me some useful link.
Thanks
July 6, 2007 at 2:17 am
July 6, 2007 at 3:12 am
A case statement in SQL can only be used within a select/update statement. It can't be used for control flow in the procedure. For the latter, use IF statements.
The form of a case statement in SQL is
SELECT CASE Field1 When 1 THEN 'One' When 2 THEN 'Couple' ELSE 'Many' END As HowMany
FROM tbl
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 6, 2007 at 3:30 am
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply