Problem in altering Column length

  • Hi All,

    I want to alter the length of columns.In doing so am getting error that which says that the column depends on defaults.Is there a way to only script or disable the defaults so that I can alter the columns and can have defaults restored afterwards.

    Regards,

    Ahmad

    Regards,
    [font="Verdana"]Sqlfrenzy[/font]

  • Ahmad Osama (8/4/2008)


    Hi All,

    I want to alter the length of columns.In doing so am getting error that which says that the column depends on defaults.Is there a way to only script or disable the defaults so that I can alter the columns and can have defaults restored afterwards.

    Regards,

    Ahmad

    You can drop the default explicitly (ALTER TABLE tablenameDROP CONSTRAINT defaultname), alter the table, then create the default again. Alternatively, you can use Management Studio to change the column (but instead of executing in the table designer, click on the Script button (usually top left corner of the screen). This will give you a script that does the job, but you can edit it to suit your needs if needed.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • thanks, but am unable to get a separate script of the defaults...the syntax is in the table definition itself, however after a close look I found that the most of the column defualt to either null or 0.Thus I hv created 2 defaults and hv a proc to bind it to the columns with default value null or 0, hence in this way am able alter the columns with min work.

    Regards,
    [font="Verdana"]Sqlfrenzy[/font]

  • Is there a way to only script or disable the defaults so that I can alter the columns and can have defaults restored afterwards.

    sp_unbinddefault

    alter table

    sp_binddefault

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

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