Articles → SQL SERVER → Case Statement In SQL Server

Case Statement In SQL Server






What Is The Case Statement?





Syntax


Case When <condition> then <value_to_be_returned_if_condition_is_satisfied> Else <value_to_be_returned_if_condition_is_not_satisfied> End



Example




Picture showing schema of Image table




Picture showing data in Image table




Select (Case When Photo is not Null then 'Exists' Else 'Not Exists' End) From [Image]




Picture showing output of case statement in SQL server



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, July 18, 2017

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250