a problem with adding fields in ssems

  • hi,

    i have a DB and it has some tables that the tables has related link (diagram).now when i wanna to change a table's field , the Sql Server errors that the table is not empty.when i try to delete the table's content , Sql server errors   that the table is use a relation with another table.

    so can i change a table's structure?

    by the way before i forget , the Sql Server's error is below:

    'UserManagement' table

    - Unable to modify table. 

    ALTER TABLE only allows columns to be added that can contain nulls, or have a DEFAULT definition specified, or the column being added is an identity or timestamp column, or alternatively if none of the previous conditions are satisfied the table must be empty to allow addition of this column. Column 'isadmin' cannot be added to non-empty table 'UserManagement' because it does not satisfy these conditions.

    thanks,

    M.H.H

  • Check to make sure that you did not uncheck the "Allow Nulls" column. Since the table already has data in it, you will not  be able to require an entry in this column until you have populated the existing records with valid data. Then you can come back and uncheck the "Allow Nulls" column.

    HTH,

    Carla


    Regards,

    Carla Hepker
    Documentation: A Shaft of light into a coded world.

  • if you need the new column(s) to be NOT NULL constrained, you can accomplish what you want in two steps.  first create the column you want and provide a default value.  then update values to what you actually want them to be.  finally, turn off the default value.

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

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