nested IF in t-sql

Does t-sql support nested ifs or an equvalent.  I am trying to do something like.

if expression
  Begin
    print 'xxx'
    if expression2
       BEGIN
         print 'yyy'
         print 'zzz'
       END
ELSE
  begin
      print 'aaa'
      print 'bbb'
  end
I get 'syntax error near ELSE'  I have not seen an example of such so that would be helpful also
 
xoxomosAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tchalkovCommented:
It does support it, but you have a missimg end before else
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NaelCommented:
of course it does !!
but as tchalkov said, you missed the last end.
0
simonsabinCommented:
just to help
Your code should be


if expression
  BEGIN
    print 'xxx'
    if expression2
       BEGIN
         print 'yyy'
         print 'zzz'
       END
  END
ELSE
  BEGIN
      print 'aaa'
      print 'bbb'
  END
0
manpakhongCommented:
On situation I have encounted is that the
----------------
if
begin
     if
     begin
           <statement here>
     end
end
-----------------
must have statement between (every begin) and (end part)
otherwise it will have syntax error


Man Pak Hong
manpakhong@hotmail.com
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.