Looks perfect. But a few questions
Won't this affect the update and the delete procedures. Do I need to change the update and the delete procedures also? Please let me know.
Thanks
Srikumar
Main Topics
Browse All TopicsHi,
I want to replicate a table config_t( I am using transactional replication).
All the column except one can be replicated with out any change.
But for this one column I want to assign a default value when I replicate.
Again this default value will be obtained by querying certain tables in the subscription database.
How can I do this? Any help on this will be highly appreciated. I am using SQL server 7.0 in NT.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
this depends on what you're trying to do, but most likely no.
if you insert a new row, you obviously need a default value inserted. for update, do you want that no matter what "default column" is updated with by publisher, it is always set to your default value ? if yes, then modify sp_msupd_ stored procedure to reflect that, otherwise -- leave it as it is. as for sp_msdel_ procedure, i can't come up with a scenario why would you need to modify it for your problem.
so, leave sp_msupd_ and sp_msdel_ procedures as they are, since they have little to do with our custom sp_msins_ procedure.
mitek
another thing, very important.
make sure you script your custom stored procedure and keep the code someplace; every time you resynchronize (or resubscribe), your custom sp_msins_ procedure will be replaced with default version. so, whenever this happens, you'll have to remember to delete the default sp and replace it with your custom code.
I just want to confirm something.
I am using read only transactional replication
As I specified in my question, I need to query a table from the destination database. (That is from the subscriber, not the publisher). Do you think the logic you told will work? Because we are creating the sp_msupd_ and sp_msdel_ and sp_msins_ procedures when we create the publication.
Can you please confirm this? Thanks
if you really want, in Create Pulication wizard, in Add Articles screen (by clicking on (...) next to each pulished table), you may disable creation of default sp_msxxx_ stored procedures, in which case when you resubscribe, you won't lose your custom code. however, you'll have to make sure all 3 procedures are correct and available on the subscriber.
> Do you think the logic you told will work ?
i don't see why not. but, should something happen to the connection b/w servers, destriution agent will stop (you'll see big red X-s in Replication Monitor) and will have to be manually started. safest way, unsubscribe & resuscribe again. when you do that, you'll lose your custom unless you disabled sp creation as i explained above.
> Do you think the logic you told will work ?
i don't see why not. but, should something happen to the connection b/w servers, destriution agent will stop (you'll see big red X-s in Replication Monitor) and will have to be manually started. safest way, unsubscribe & resuscribe again. when you do that, you'll lose your custom unless you disabled sp creation as i explained above.
Ok. I tested this. It works fine for the transactions which happen after the snapshot creation. But for the data which is loaded using the initial snapshot this is not working.
I think this is because the initial loading is done using bcp and not the insert statments. Do you know any thing to take care of this situation?
Business Accounts
Answer for Membership
by: mitekPosted on 1999-08-23 at 17:08:58ID: 1097773
when you set up replication on a subscriber, the wizard creates three stored procedures for each replicated table, such as sp_msins_TABLE1,sp_msupd_T ABLE1 and sp_msdel_TABLE1, where TABLE1 is placeholder for table name.
========== ========== ========= ========== ========== =========
========== ========== ==========
========== ========== ==========
every transaction (INSERT,UPDATE or DELETE) that logreader scans from transaction log on publisher is translated into a call to one of these three procedures. the whole purpose of all this fuss is ability to customise the way the replicated data make its way into subscriber.
here is a sample sp_msins_ procedure:
==========================
CREATE PROCEDURE sp_MSins_TABLE1 @c1 int, @c2 varchar(20), @c3 varchar(50), @c4 varchar(20) AS
INSERT INTO TABLE1(id, name, address, marker)
VALUES (@c1, @c2, @c3, @c4)
RETURN
==========================
let's say we want field "marker" be the "default column" which we want to obtain by quering some other tables.
to do that, we'd turn our default sp into something like this:
==========================
CREATE PROCEDURE sp_MSins_TABLE1 @c1 int, @c2 varchar(20), @c3 varchar(50), @c4 varchar(20) AS
DECLARE @marker varchar(20)
SELECT @marker = marker FROM dname.dbo.TABLE2
WHERE id = @c1 + 1000
INSERT INTO TABLE1(id, name, address, marker)
VALUES (@c1, @c2, @c3, @marker)
RETURN
==========================
then, every replicated insert transaction will make on-the-fly conversion of your special data column and turn it into whatever you like.
leave comments if you're still having questions about your replication problem, i'll try to answer them as soon as i can ...