views:

67

answers:

1

Using sp_repladdcolumn I can either:
1) add a column that allows nulls; or
2) add a column with a default value that does not allow nulls.

Without dropping and recreating the whole subscription I would like to:
3) add a column with no default value that does not allow nulls.

Is this possible?


I realize I would need to populate the column with data before I could set it to NOT NULL. As the title indicates, what I really want to do is rename an existing column that: a) has data in it, b) is set to NOT NULL, and c) has no default value.

A: 

To just rename a column, why not just use sp_rename?

Chris Shaffer
Fails with this error:Msg 15051, Level 11, State 1, Procedure sp_rename, Line 172Cannot rename the table because it is published for replication.
mwolfe02
Sorry - I would downvote myself for not reading the question closely enough to notice the parts about replication if I could. I don't know too much about replication, but on a standard table if I wanted to add a new non-nullable column I would add it with a default then drop the default constraint... Is that an option?
Chris Shaffer
There does not appear to be any way to alter a column (to include dropping the default constraint) without turning off the merge replication, making the alteration, then turning it back on. Unfortunately, turning the replication off and on is not trivial. It can be scripted easily enough but it takes several hours to regenerate the snapshot and all of that work must be done when the users are not around (i.e., night/weekend) which I'd like to avoid if possible. I can enforce the NOT NULL through the front-end, but I would prefer to have the database engine handle that itself.
mwolfe02