title: Sybase: if-else error
body: <p>I have the following if-else statement in SAP Interactive SQL (Sybase):</p>
  
  <pre><code>IF EXISTS (SELECT 1 FROM sysobjects o, sysusers u WHERE o.uid=u.uid AND o.name = 'mytable' AND u.name = 'user1')
      BEGIN
          PRINT "Dropping table mytable"
          DROP TABLE mytable 
          PRINT "Dropped table mytable"
      END
  ELSE
      BEGIN
          PRINT "Table mytable does not exist" 
          SELECT * INTO mytable FROM mytable2
          PRINT "Table mytable copied from mytable2"
      END
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>"Could not execute statement. There is already an object named named 'mytable' in the database."
  </code></pre>
  
  <p>If I get rid of the else clause it checks for the table and if it exists it drops it as expected. But together with the else clause it chooses that last one whether the original table exists or not. Hence the error message that the table already exists. What is the problem here? I think I got the syntax right (taken from the sybase documentation and other sources).</p>