Hi,
I want to use switch - case statement in T-SQL stored procedure.
Can any one help regarding the same..?
for e.g.
switch (exp)
{
case 1 : stmt 1; break;
case 2 : stmt 2; break;
case 3 : stmt 3; break;
& so on.......
}
Hi,
See the following example
DECLARE @.TestVal int
SET @.TestVal = 3
SELECT
CASE @.TestVal
WHEN 1 THEN 'First'
WHEN 2 THEN 'Second'
WHEN 3 THEN 'Third'
ELSE 'Other'
END
No comments:
Post a Comment