How to add a constant column when replicating a database?

Question :

How to add a constant column when replicating a database?,

Answer :

I am using SQL Server 2000 and I have two databases that both replicate (transactional push subscription) to a single database. I need to know which database the records came from.

So I want to add a fixed column specified in the publication to my table so I can tell which database the row originated from.

How do I go about doing this?

I would like to avoid altering the main databases mostly due to the fact there are many tables I would need to do this to. I was hoping for some built in feature of replication that would do this for me some where. Other than that I would go with the view idea.

Read More  Hidden Features of C#?

,

You could use a calculated column Use the following on the two databases:

  ALTER TABLE TableName ADD      MyColumn AS 'Server1'  

Then just define the single “master” database to use a VARCHAR column (or whatever you want) that you fill using the calculated columns value.

That’s the answer How to add a constant column when replicating a database?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

Read More  Does anyone still believe in the Capability Maturity Model for Software?

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you