How to handle DDL errors in T-SQL??

  • Hi,

    I have a insert statement in which destination table does not exist, in this case transaction will be uncommitted as it cannot handled neighter by @@Error nor by try catch. is there any solution where i can handle DDL errors?

  • Hi

    Check whether the table exists and then insert.

    "Keep Trying"

  • Even if table exist now, I want to handle this situation in future any table is dropped and I dont want my SP to suffer. so any workaround on it?

  • Yup... check for the tables existence before doing the inserts using IF EXISTS.

    BTW what do you mean by table is dropped in future? Its better to check before dropping a table.

    "Keep Trying"

  • [font="Verdana"]

    guptaopus (5/8/2008)


    Even if table exist now, I want to handle this situation in future any table is dropped and I dont want my SP to suffer. so any workaround on it?

    Anyway Chirag is absolutely right. You need to check whether the table exists or not. If so, then and then only go for Insert otherwise in else part raise error that table is not present in DB. Its so Simple. Why you need to worry about dropping table then? You SProc is not going to suffer anyway.

    Mahesh[/font]

    MH-09-AM-8694

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

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