Editing replication stored procedures

  • Just wanted a high level answer really on whether or not it is a good idea to alter the sql replication stored procedures.

    Reason I ask is that we have a need for replication but the destination table has many additional columns to the source and a proposed solution is to set up transactional replication but customise the sprocs to retrieve additional information.

    I have to admit I dont particulalry like the idea but I might be being a little too cautious, is it a reasonable solution to consider?

    'Only he who wanders finds new paths'

  • david.alcock (2/4/2013)


    Just wanted a high level answer really on whether or not it is a good idea to alter the sql replication stored procedures.

    Reason I ask is that we have a need for replication but the destination table has many additional columns to the source and a proposed solution is to set up transactional replication but customise the sprocs to retrieve additional information.

    I have to admit I dont particulalry like the idea but I might be being a little too cautious, is it a reasonable solution to consider?

    Don't do it!!! What happens when the next update gets released and overwrites your changes? It is generally a very bad idea to alter the MS stored procs.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • You can create your own sprocs for use by replication. Have a look at what the MS generated sprocs do (and in particular, the parameter) and then use that as the basis for your own, which you would code to lookup the extra values etc.

    When you create the article(s) in the publication, just specify you custom sprocs and away you go. You will need to make sure that that exist - either create them directly or add them in a script that is run by replication when the subscription is established. I suspect that, since you have table definitions at your subscriber that are different from your published, it would probably easier for you to create the sprocs in advance.

  • Thank you both for the replies.

    Certainly altering the system sprocs are a no no, it did sound fundamentally...well wrong to me! Alternatively, having customised scripts does sound interesting. I just wonder if its more straightforward to allow replication to continue then use SSIS to perform any necessary transformations.

    'Only he who wanders finds new paths'

  • If you were to use the standard MS Stored Procs? At what point would they get overwritten? Setting up replication again?

  • ian.hewitt 52640 (2/5/2013)


    If you were to use the standard MS Stored Procs? At what point would they get overwritten? Setting up replication again?

    They have the potential of being overwritten when you update sql server. Service packs, etc. The real problem is that by the time the next service pack is release you forget that you changed those sprocs and everything comes crashing down until you figure out what the changes you need to make are now when sproc you changed is different. Another very real possibility is that you are at another job and nobody knows what the change was or why it was made.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • I see your point around the risk, but ....Should a service pack over write stored procedures that are created for a specific subscriber? I can't see why they would...!?

    I believe the real question here is wether SQL Replication is a suitable "engine level" technology to use when syncronising from a database where the tables and associated columns don't exactly match the subscribing database structure!?

    Would you suggest using "custom" stored procedures, if they MS ones could disappear?, to overcome the problem and, in effect, filter the data (reduce columns) from the publishing DB to the subscriber DB. Surely custom sprocs would be "safer"!?

    Also having a proper package release process would over come problems when installing service packs as you would have the correct package to "re-install" any customisation!?

  • The one argument I have against this is that the more customisation that going into these stored procedures surely increases the possibility of failure. In my opinion the high availability of data that you gain from using replication is comprimised greatly. Surely if a high amount of customisation is required then replication might not be the ideal solution in the first place?

    Again, maybe I am being over cautious but I would rather manipulate data than manipulate system generated objects?

    'Only he who wanders finds new paths'

  • I can't believe that Microsoft have a section (with replication setup) that specifically allows you to provide customised stored procedures as part of the replication engine!!! If they didn't want you messing with it why would they provide a mechanism to change it?

    I don't mean to be argumentative but I can't believe someome out there hasn't achieved this type of replication!!!!!?????

    Maybe tech people have lost the true, can do spirit amidst all the setup wizards!

  • Microsoft allows auto shrink and auto growth at the same time in SQL, it certainly doesnt mean its a wise decision to actually do it 🙂

    'Only he who wanders finds new paths'

Viewing 10 posts - 1 through 9 (of 9 total)

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