Showing posts with label sp_repladdcolumn. Show all posts
Showing posts with label sp_repladdcolumn. Show all posts

Tuesday, March 6, 2012

Add new primary key column for replicated table with pull subscrip

I need to add a new column to a replicated table. But in my case a new column should be a part of a primary key. So, I can't use sp_repladdcolumn procedure since we need to completely repopulate the whole table and there is no default value for a new colu
mn. In addition to that this column should be first in the table's columns list, not the last one what happens when you usually alter the table adding a new column.
More there, I have a pull subscription and it looks like there is no way to drop subscription for a specified article only, like it is possible for a push subscription. I would appreciate any help pointing to an easiest way to add a new primary key column
for a replicated table with pull subscription.
TIA
Libra,
ordinarily you should be able to use sp_droparticle, sp_addarticle and
sp_refreshsubscriptions however to add the new column in a specific position
you'll need to drop the published article then recreate it and resubscribe.
You might use a nosync subscription to make things easier if the snapshot is
particularly large, but this will have restrictions if you later want to add
an article or column, so I'd recommend initializing with the complete
snapshot as per usual.
HTH,
Paul Ibison
(BTW no doubt you have seen other threads on this but placing columns in a
particular order is not generally considered 'good form' as TSQL should
ideally use explicit column names rather than rely on position.)

Friday, February 24, 2012

add column to updateable subscription

sql2k sp3
Ive got a Publication with a Subscription that is
Immediate Updating with Queued for Failover. I tried to
run sp_repladdcolumn and got:
Server: Msg 21381, Level 16, State 1, Procedure
sp_repldropcolumn, Line 277
Cannot add (drop) column to table 'transdtl' because the
table belongs to publication(s) with an active updatable
subscription. Set @.force_reinit_subscription to 1 to force
reinitialization.
Server: Msg 21284, Level 16, State 1, Procedure
sp_repldropcolumn, Line 637
Failed to drop column 'test' from table 'transdtl'.
So how do you gurus add a column in this scenario? Do I
actually need to re snapshot the table? The only other
option I can think of would be:
Add them to the tables without sp_repladdcolumn. Add them
as an Article. Generate the Procs and Triggers for them.
Hmmm. That would suck.
TIA, Chris
I take it you are dropping a column. Your post is a little unclear to me.
do a sp_repdropcolumn with @.force_invaldiate_snapshot=1,
@.force_reinit_subscription=1
Hilary Cotter
Looking for a book on SQL Server replication?
http://www.nwsu.com/0974973602.html
"ChrisR" <anonymous@.discussions.microsoft.com> wrote in message
news:76ea01c47679$327475b0$a601280a@.phx.gbl...
> sql2k sp3
> Ive got a Publication with a Subscription that is
> Immediate Updating with Queued for Failover. I tried to
> run sp_repladdcolumn and got:
> Server: Msg 21381, Level 16, State 1, Procedure
> sp_repldropcolumn, Line 277
> Cannot add (drop) column to table 'transdtl' because the
> table belongs to publication(s) with an active updatable
> subscription. Set @.force_reinit_subscription to 1 to force
> reinitialization.
> Server: Msg 21284, Level 16, State 1, Procedure
> sp_repldropcolumn, Line 637
> Failed to drop column 'test' from table 'transdtl'.
>
> So how do you gurus add a column in this scenario? Do I
> actually need to re snapshot the table? The only other
> option I can think of would be:
> Add them to the tables without sp_repladdcolumn. Add them
> as an Article. Generate the Procs and Triggers for them.
> Hmmm. That would suck.
>
> TIA, Chris