Sunday, February 19, 2012

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

First, add the column to the table, allowing values to be NULL, or provide a 'starting out' (DEFAULT) value.

ALTER TABLE UserManagement
ADD IsAdmin int NULL
-->OR<--
ADD IsAdmin int DEFAULT 0

Then, update the table to provide the values you want the rows to have.

|||

hi,thanks for ur attention,

my problem is solved,

M.H.H

No comments:

Post a Comment