Results 1 to 2 of 2

Thread: alter Script

  1. #1
    Join Date
    Sep 2002
    Posts
    218

    alter Script

    l'm running this script to drop and recreate my columns .But when l run it l get the following error. l want to add the column class with a
    default of 'A' but l keep gettint the above error.pLEASE HELP

    Server: Msg 5074, Level 16, State 1, Line 1
    The object 'DF_Ray_Class' is dependent on column 'Class'.
    Server: Msg 4922, Level 16, State 1, Line 1
    ALTER TABLE DROP COLUMN Class failed because one or more objects access this column.
    Server: Msg 2705, Level 16, State 4, Line 2
    Column names in each table must be unique. Column name 'Errno' in table 'Ray' is specified more than once.


    Alter table Ray
    drop column
    Errno
    ,Errstr
    ,Telno
    ,NewTelNo
    ,NewTelType
    ,Class
    Go

    Alter Table Ray Add
    Errno int NULL
    ,Errstr varchar (100)
    ,Telno varchar (30)
    ,NewTelNo varchar (20)
    ,NewTelType varchar (20)
    ,Class char (3)
    CONSTRAINT [DF_Ray_Class] DEFAULT ('A')
    Go

  2. #2
    Join Date
    Oct 2002
    Location
    Atlanta, Georgia, USA
    Posts
    1
    You need to drop the constraint before dropping the column.

    alter table drop constraint DF_Ray_Class
    GO

    Alter table Ray
    drop column
    Errno
    ,Errstr
    ,Telno
    ,NewTelNo
    ,NewTelType
    ,Class
    Go

    Alter Table Ray Add
    Errno int NULL
    ,Errstr varchar (100)
    ,Telno varchar (30)
    ,NewTelNo varchar (20)
    ,NewTelType varchar (20)
    ,Class char (3)
    CONSTRAINT [DF_Ray_Class] DEFAULT ('A')
    Go

Posting Permissions

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