• Hi.

    It would go something like this.

    Step 1

    First, add your new column.

    Alter table TableName add NewCol int default(0) not null

    I think that you must have a not nullable column. If I remember correctly, MSSql Server doesn;t like making primary keys from nullable columns.

    You can accomodate this in an alter table by adding a default constraint then declare it as not null.

    Step 2. Load the values into the new column. since the table had 1000 rows in it, now those are all set to the value of the default constraint. Since you are ablout to make this column a primary key, there must be unique values for each row in the new column.

    Step 3. Create the primary key constraint

    alter table TableName add constraint New_primary_key primary key (NewCol)

    Optionally, you could remove the default constraint on the new column.