all groups > sql server replication > december 2004 >
You're in the

sql server replication

group:

Add a field to target table?


Add a field to target table? AndersBj
12/29/2004 6:19:02 AM
sql server replication:
I would like to add a field to a table that is the target table in a
transactional replication. The source table does not have this field (and
never will). Can it be done without interfering with the existing replication?

Thanks in advance,

Re: Add a field to target table? Hilary Cotter
12/29/2004 10:24:31 AM
nope.

You will probably have to either create a custom sync object, replicate an
indexed view which looks like your table on the subscriber, or do a nosync
and edit the stored procedures for the different schema on the subscriber.

--
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
[quoted text, click to view]

RE: Add a field to target table? AndersBj
12/30/2004 12:09:02 AM
Thanks for your answer. After I posted this question I did a small test by
setting up a transactional replication between two databases on the same SQL
server.

The publisher in db A had the following fields in table X:
ID, name, email

The subscriber in db B had the following fields in table X:
ID, name, email

I then added a field to the subscriber table X, to make it look like this:
ID, name, email, age

This worked without any problems, new items replicated from db A to db B
just left age being null. Can this little test of mine prove that the concept
works or is there something else I should consider??

Thank you,

/Anders


[quoted text, click to view]
RE: Add a field to target table? AndersBj
12/30/2004 12:35:02 AM
Hmm, did some further testing and realized that if a new snapshot ever should
be required, my changes on the table in db B would be overwritten... so I
guess this isn't a good solution after all...



[quoted text, click to view]
Re: Add a field to target table? AndersBj
12/30/2004 11:49:05 AM
Thank you, I will try this as soon as possible.

/Anders



[quoted text, click to view]
Re: Add a field to target table? Paul Ibison
12/30/2004 6:48:34 PM
Anders,
on the subscriber you could have the extra column, ensuring it is recreated
is easy is done using @creation_script argument of sp_addarticle. How to
ensure the data isn't lost? Use an instead-of trigger on the subscriber to
input the changes to the extra column into an audit table to ensure they're
not lost.
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

AddThis Social Bookmark Button