In this article I am going to explain about Sql Server’s CASE expression.
Case statement is also known as CASE expression. We can use CASE expression anywhere in Sql query. It can be used with in select, where clauses, Order by clause, HAVING clauses, insert, update and delete statements.
Simple case expression Example:
WHEN value_1 THEN result_1
I have created a table CountryCode and insert some dummy record into it.
when CountryCode='IN' then 'India'
when CountryCode='US' then 'United States of America'
when CountryCode='CU' then 'Cuba'
when CountryCode='GB' then 'United Kingdom'
end as [Country Name]
What do you think about this article?
If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.