Replication Issue - URGENT - Please help!

  • Hi all...I just got handed the job of deploying TFS/DBPro packages to our servers. I have had no problems in this new position UNTIL I tried to deploy an ALTER TABLE statement to a replicated table!! I BROKE REPLICATION!! Yikes!! So, of course I have an URGENT request to get some stuff up on TESTBED and it is more alter table statements, mixed in with some other view/proc changes. I am a replication NEWBIE and I need your help!

    So...I have been doing some reading today, but wanted to see if I can get some quick answers from you all that have done this before and save me some time that I desparetly need. So, thank you in advance....

    My question is this: I found this code (see below)....can I incorporate it WITHIN my other alter script, or do I need to break out the replicated tables being altered and put it in a script by itself??

    Next question: Is this syntax done for each table replicated and so I would just append this same code over and over until my changes are complete??

    Thank you for any help, I appreciate it!! :w00t:


    Thank you!!,

    Angelindiego

  • One more piece of info I wanted to share....I opened up the replication script for TESTBED and it has in there the variable @replication_DDL = 1 (I think that was it...). I understand this to be that it would replicated altered tables....but it didn't.....so any thoughts????? Thank you again!!


    Thank you!!,

    Angelindiego

  • If i understood correct, you are trying to alter a table which is involved in replication. You cannot alter table or do schema changes if the schema changes option is set to false in publisher properties. Change schema changes setting to true if you want to make changes at publisher table and propagate to subscriber, or remove the table from publisher do schema changes and then add back the table to publisher and re initialize subscriber.

    EnjoY!

    EnjoY!
  • Angelindiego (3/8/2010)


    My question is this: I found this code (see below)....can I incorporate it WITHIN my other alter script, or do I need to break out the replicated tables being altered and put it in a script by itself??

    I see no code, do you have the code?

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Hi There,

    Got couple of questions before anyone can give any good info..

    1. What kid of replication do you have?

    2. You state that you have some code in the message. Cant seem to find it. Can you post it again?

    3. What kind of Alter statement was it? (Adding column, removing column etc)

    -Roy

  • Angelindiego (3/8/2010)


    One more piece of info I wanted to share....I opened up the replication script for TESTBED and it has in there the variable @replication_DDL = 1 (I think that was it...). I understand this to be that it would replicated altered tables....but it didn't.....so any thoughts????? Thank you again!!

    That should replicate changes to the subscriber if implemented properly.

    exec sp_changepublication @publication = 'pubname'

    , @property = 'replicate_ddl'

    , @value = '1'

    , @force_invalidate_snapshot = 0

    , @force_reinit_subscription = 0

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • OOPS, I forgot to paste in the code that I found...sorry!!

    exec sp_dropsubscription @publication = 'tTestFNames'

    , @article = 'tEmployees'

    , @subscriber = 'RSCOMPUTER'

    , @destination_db = 'testrep'

    exec sp_droparticle @publication = 'tTestFNames'

    , @article = 'tEmployees'

    alter table tEmployees alter column Forename varchar(100) null

    exec sp_addarticle @publication = 'tTestFNames'

    , @article = 'tEmployees'

    , @source_table = 'tEmployees'

    exec sp_addsubscription @publication = 'tTestFNames'

    , @article = 'tEmployees'

    , @subscriber = 'RSCOMPUTER'

    , @destination_db = 'testrep'


    Thank you!!,

    Angelindiego

  • this is transactional replication and there is both drop columns and add columns and I am looking now to see if there were any other constraint issues too....


    Thank you!!,

    Angelindiego

  • You said Broken Replication, what is the error message? Check the constarints too.

    EnjoY!

    EnjoY!
  • In SQL 2005, you can modify tables that are being replicated. For this first you will have to change the publication properties for Replicate Schema Changes to TRUE. Once that is done, you can just do alter table scripts. You do not have to drop the subscription or drop the article.

    Once you set that change, you can just give the Alter table. (Some pre-requisites are there)

    You can do

    Alter Table TableName Add ColumnName int NULL

    The pre-requisite is it has to be either a NULL column or should have a default set to it.

    You can change the size of a column with no issue if you are doing through the script. But if you try to change it through the SSMS GUI, it will give an error since the GUI tries to drop the table and add the table back when altering.

    One thing to watch out for is you cannot add an Identity column to the publisher

    -Roy

  • ok, for today's issue....I have a deployment that includes 3 alter tables (2 with add columns, 1 with a drop column and an add column) and add a default constraint to each. Also, 4 views that are being altered (but those don't cause issues). I am just wondering if it can all be done in the same script, or do I need to break out the alter tables stuff????


    Thank you!!,

    Angelindiego

  • Here is a small piece of advice. Which ever method you choose to do, first test it on a testing environment. You can use your script that you put. That is drop Subscription, drop the article, Alter the table and then add it back to replication or Set the Replicate Schema Change to TRUE and then just give ALTER Table commands through your SSMS Query window.

    Dont try to do it in production until you have tested the scripts.

    -Roy

  • It doesn't matter, it is your call!

    EnjoY!

    EnjoY!
  • Roy, where is this set :Set the Replicate Schema Change to TRUE

    In the replication script that I printed out, I see this: @replicate_ddl = 1.....is that the same thing??


    Thank you!!,

    Angelindiego

  • It is in the Publication/Properties/Subscription Options. Or as the script says @replicate_ddl = 1.

    But by default the setting should be true. That is enabled. I wonder why it is disabled in your setting.

    -Roy

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic. Login to reply