The reason is that the entire if statement and its "true" part are compiled as one.
If the table exists at compile time - an error.
So you can put the CREATE TABLE statement in dynamic sql statemetn EXEC('CREATE TABLE....')
Then everything that Sybase sees when compiling:
IF object_id('mytab') IS NULL EXEC('something or other')
EXEC content does not compile before execution, when you do not know that there is no table, and all is well.
source share