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.
Join our Facebook
page to get updates of Jobs, Interview Question, Course Details and Study
Material
No comments:
Post a Comment