Structure Change Problem

  • I have a table with a field:

    cfield1 char(10) NOT NULL default ''

    I need to change this field programatically to:

    cfield1 varchar(100) NOT NULL default ''

    To do this, I have to drop the constrant and then change the field with alter table ?? alter column ??? The problem with this is that I can not add the Default '' to this statement

    How Can I make this change and keep the Default '' constrant

  • Your Answer is Today's QOD

    
    
    ALTER TABLE MyTable DROP CONSTRAINT MyConstraint
    GO

    ALTER TABLE Mytable
    ALTER COLUMN Mycolumn varchar(100)
    GO

    ALTER TABLE MyTable ADD CONSTRAINT MyContraint DEFAULT 'New' FOR MyColumn
    GO


    * Noel

Viewing 2 posts - 1 through 1 (of 1 total)

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