Showing posts with label if-else statement in sql server. Show all posts
Showing posts with label if-else statement in sql server. Show all posts

Wednesday, 20 March 2013

Use of If –else statement in SQL Server


Use of If –else statement in SQL Server

We can also use if-else statement in SQL Server also.
Syntax for using if else is as follow:-
If(condition)
Begin
------------------------- working----------------------
End
Else
Begin
----------------------- working …………………..
End
For example:-
declare @id int;
set @id=10;
if(@id>5)
begin
print 'you have entered value more than 5';
end
else
begin
print 'you have entered value below 5'
end
When we execute the complete statement it will return the output as follows:-
‘You have entered value more than 5’
Similarly you can use nested if-else in it.
Hope you enjoyed the article.
hope you enjoyed this article. For any query you can mail me at malhotra.isha3388@gmail.com.
Join our Facebook page to get updates of Jobs, Interview Question, Course Details and Study Material