How to find default object in the systables?

  • Dear all,

    I have a table COLOR with an obsolete column CODE NVARCHAR(8) DEFAULT '' (Empty String). When I want to drop the column I receive the error: Server: Msg 5074, Level 16, State 1, Line 1

    The object 'DF__COLOR__CODE__13D789BB' is dependent on column 'code'.

    Question: where can I find this objects in the systables in order to write a script to remove this object?

    Gerald


    Dutch Anti-RBAR League

  • I couldn't find this from the information_schema views, so I resorted to:

    select  sot.[name] as 'Table Name',

     sc.[name] as 'Column name',

     sod.[name] as 'Default Name'

    from  sysobjects sot

      inner join

     syscolumns sc

      on sot.[id] = sc.[id]

      inner join

     sysobjects sod

      on sc.cdefault = sod.[id]

    where  sod.xtype = 'd'

    and sot.xtype = 'U'

    Hope it helps

  • The DEFAULT value can be found when you open the table in EM.  Just DELETE the DEFAULT from the column and you should be good to go.



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Thank you Wanderer, the SQL statement was exactly what I needed!


    Dutch Anti-RBAR League

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

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