Errors executing ALTER TABLE table DROP COLUMN [column]


  • Well I already looked at themes alike my current problem but nothing seems to fit perfectly .. so a new post:

    i have a rather long sql-script, from exporting with phpmyadmin and use it to migrate the database to SQL-Server Express 2008 R2 - I change column definitions where needed and everything works fine. But the last table is created from another table (insert ... select) and after that I want to remove the now unnecessary columns from the "source"-table

    But then :

    Msg 5074, Level 16, State 1, Line 1
    The object 'DF__tickets__flag__5F141958' is dependent on column 'flag'.
    Msg 4922, Level 16, State 9, Line 1
    ALTER TABLE DROP COLUMN flag failed because one or more objects access this column.

    Exact Syntax:


    TABLE tickets DROP COLUMN flag;


    I can easily drop the columns using SQL Server Management Studio (Express) - but I need to do it with the script since on the final server there wont be a management suite

    So what can I do to resolve it - I guess that the "DF_...." object is created dynamically, so next time I do the import  it will get a new name .. is there some kind of SET-Statement that lets me drop the column like it works in other databases?

    thanks for your support

    First : I didnt create any views and the column doesnt have any real constraints aside from a simple  default value (create statement says: flag integer default NULL, )

    • แก้ไขโดย Sven Leuschner 29 กันยายน 2554 7:28
    29 กันยายน 2554 7:25