Tuesday, February 14, 2012

Can a column data type be changed on a replicated table?

On sqlserver 2000 transactional replication:

How would I best go about changing a published table's column from smallint to int? I could not find anything about it in BOL or MS.com. I do not think EM/Replication Properties allows the change. I suspect I have to run "Alter Table/Column" on the Publisher and each Subscriber the old-fashioned way. Is that true?

Thanks!

In SQL 2000, the only way to do this is to drop the article column, make your change, then re-add the article column. You can do this via sp_repldropcolumn and sp_repladdcolumn. You can find more information about these two procs in Books Online. You can also drop the entire article, make your change, and re-add the article.

In SQL 2005, there's a lot of improvement in DDL so you can do ALTER TABLE directly on the article table.

|||

Greg Y wrote:

You can also drop the entire article, make your change, and re-add the article.

Note, that in some cases (for example, if you have anonymous pull subscriptions), dropping and re-adding entire article into publication may cause subscription become obsolete and requires reinitialization.

No comments:

Post a Comment