Drop Table

  • Hi

    Begin tran

    drop table <table name>

    rollback

    end tran

    can any one help why the table is not droped and is rollbacked

  • Hi,

     you are forcefully making a rollback and asking for why it should be rollback...

    Begin tran

    drop table <table name>

    IF @@ERROR > 0

         rollback

    ELSE

        commit

    end tran

    I think it would clear your problem and slove the question

    cheers

  • Because drop table is a logged operation and you are reqesting a rollback ie undo everything up to where the transaction began.

    By the way, your code shouldn't even run. You have a syntax error. There's no such statement as End Tran in SQL Server.

    A transaction is started with Begin tran and ended with either Commit Transaction or rollback Transaction.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • So what were you trying to accomplish with this code... and how can we help you with that?

  • drop table <table name>

    is this line is DML Statement

  • That question was already corectly answered.  I have no idea what problem you are encountering.  Can you tell us more about the process and the problems you are encountering?

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply