Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    20

    Unanswered: how to modify default value for a column

    hi,
    I just want to ask how to modify the DEFAULT value for a column in a table.
    The following sql statement I'm executing from ISQL in PowerBuilder:
    ALTER TABLE table_name
    ALTER COLUMN column_name INTEGER DEFAULT 1;
    is giving the following error:
    [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'default'

    Also when I try to drop a column that has DEFAULT value:
    ALTER TABLE table1
    DROP COLUMN column1;
    It gives the following error:
    [Microsoft][ODBC SQL Server Driver][SQL Server]The object 'DF_...' is dependent on column 'column1'
    Does anyone know how to drop it?

    Thanks

  2. #2
    Join Date
    Oct 2001
    Location
    Naples, FL
    Posts
    273
    Try

    ALTER TABLE tablename ADD CONSTRAINT
    constraintname DEFAULT 1 FOR [columnname]

    HTH
    ---------------
    Ray Higdon MCSE, MCDBA, CCNA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •