-1

I have a table in first DB and I make transactional replication to create this table on second DB but I want change first column name in subscriber table.I change it but when I insert,update or delete on table of the first DB replication was failed.please help me

AP4MH
  • 19
  • 7
  • 1
    Have you tried even a basic amount of research? Check out this link for google using your exact question title. There are several links with detailed explanations. https://www.google.com/search?q=How+to+change+column+name+in+subscriber+table+in+SQL+Server&ie=utf-8&oe=utf-8 – Sean Lange Aug 01 '17 at 14:05
  • @SeanLange : yes i google it but i can't find exact answer or exact method to solve it – AP4MH Aug 01 '17 at 14:07
  • 2
    Gosh like this one. https://www.mssqltips.com/sqlservertip/2396/steps-to-rename-a-subscriber-database-for-sql-server-transactional-replication/ The second link on google. Your exact problem with a detailed explanation of how to solve it. – Sean Lange Aug 01 '17 at 14:09
  • @SeanLange : I saw this but it's for database names not for column – AP4MH Aug 01 '17 at 14:18

1 Answers1

2

To have a different table schema on a Transactional Replication subscriber is not simple.

First you have to use custom stored procedures to apply replication changes, as per Transactional Articles - Specify How Changes Are Propagated

Then you have to run a script after each Init/Reinit to re-apply the schema changes, perhaps using Execute Scripts During Synchronization

A simpler alternative is to create an indexed view on the publisher and publish that as a table. See: https://learn.microsoft.com/en-us/sql/relational-databases/replication/publish/publish-data-and-database-objects

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
  • I never thought we could modify those stored procs,thanks for the links – TheGameiswar Aug 01 '17 at 14:26
  • I changed my column name and modify 3 stored precedures that sql server created **sp_MSdel_dboUsers** **sp_MSins_dboUsers** **sp_MSup_dboUsers** Just change UserID to ID in all of them it's work but I don't know its the right way – AP4MH Aug 01 '17 at 16:28