Use of switch and while loop in sql server 2005
How to use Switch case in Sql server 2005, pls give me some example of swich and while loop in sql server 2005
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 9, 2012, 11:29 PM EST
http://msdn.microsoft.com/en-us/library/ms181765(SQL.90).aspx
http://msdn.microsoft.com/en-us/library/ms178642(SQL.90).aspx
Notice that it's just called a CASE expression, not SWITCH CASE.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 10, 2012, 6:06 PM EST
In SQL server, there is no swich case.
but you may use case - when with select statement.
example.
Declare @ListPrice as int.
// set value of @ListPrice
SELECT CASE
WHEN ListPrice = 0 THEN 'Mfg item - not for resale'
WHEN ListPrice < 50 THEN 'Under $50'
WHEN ListPrice >= 50 and ListPrice < 250 THEN 'Under $250'
WHEN ListPrice >= 250 and ListPrice < 1000 THEN 'Under $1000'
ELSE 'Over $1000'
END
hope this help.