Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Question on Transaction Replication

Author  Topic 

future_is_me
Starting Member

14 Posts

Posted - 2013-02-05 : 15:11:13
Hello,

I am using SQL Server 2008 R2 SP1 SE. I have a question on transaction replication.In transaction replication is there a way that I can restrict the updates specific only to a column? Lets say if updates occur on source table(publisher database) on column a, column b and column c then I dont want any thing to get updated in the destination database tables (subscriber database). But if update occurs only on column d on source table(publisher database) then I want it to get updated in destination table too (subscriber database). Is this possible?

Thanks

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2013-02-05 : 16:38:56
Yes you can choose certain columns for which you want to replicate. If you donot want you can deselect.
Go to Top of Page

future_is_me
Starting Member

14 Posts

Posted - 2013-02-05 : 17:53:04
quote:
Originally posted by sodeep

Yes you can choose certain columns for which you want to replicate. If you donot want you can deselect.



I think my question was confusing. I know we can replicate only certain columns from publisher to subscriber.

My question is:
when updates occur on publisher I dont want them to replicate to subcriber. I want to update subscriber data iff(if and only if) only a specific column value gets updated in publisher.

If there is a solution for it. can you please direct me to that url or guide me.

Thanks a bunch
Go to Top of Page

future_is_me
Starting Member

14 Posts

Posted - 2013-02-06 : 09:47:21
I found the stored proc that needs to be modified. I am not sure where the changes have to be made and I need some help from experts on this. I am not good at TSQL. The reason I chose the replication was that the deployment option was available handy.

USE [CCF_SubscriberDB]
GO

/****** Object: StoredProcedure [dbo].[sp_MSupd_dbo2006] Script

SET QUOTED_IDENTIFIER ON
GO

ALTER procedure [dbo].[sp_MSupd_dbo2006]
@c1 datetime = NULL,
@c2 int = NULL,
@c3 int = NULL,
@c4 int = NULL,
@c5 int = NULL,
@c6 int = NULL,
@c7 money = NULL,
@c8 nvarchar(20) = NULL,
@pkc1 datetime = NULL,
@bitmap binary(1)
as
begin
if (substring(@bitmap,1,1) & 1 = 1))
begin
update [dbo].[2006] set
[Date] = case substring(@bitmap,1,1) & 1 when 1 then @c1 else [Date] end,
[col1] = case substring(@bitmap,1,1) & 2 when 2 then @c2 else [col1] end,
[col2] = case substring(@bitmap,1,1) & 4 when 4 then @c3 else [col2] end,
[col3] = case substring(@bitmap,1,1) & 8 when 8 then @c4 else [col3] end,
[col4] = case substring(@bitmap,1,1) & 16 when 16 then @c5 else [col4] end,
[col5] = case substring(@bitmap,1,1) & 32 when 32 then @c6 else [col5] end,
[col6] = case substring(@bitmap,1,1) & 64 when 64 then @c7 else [col6] end,
[col7] = case substring(@bitmap,1,1) & 128 when 128 then @c8 else [col7] end
where [Date] = @pkc1
if @@rowcount = 0
if @@microsoftversion>0x07320000
exec sp_MSreplraiserror 20598
end
else
begin
update [dbo].[2006] set
[col1] = case substring(@bitmap,1,1) & 2 when 2 then @c2 else [col1] end,
[col2] = case substring(@bitmap,1,1) & 4 when 4 then @c3 else [col2] end,
[col3] = case substring(@bitmap,1,1) & 8 when 8 then @c4 else [col3] end,
[col4] = case substring(@bitmap,1,1) & 16 when 16 then @c5 else [col4] end,
[col5] = case substring(@bitmap,1,1) & 32 when 32 then @c6 else [col5] end,
[col6] = case substring(@bitmap,1,1) & 64 when 64 then @c7 else [col6] end,
[col7] = case substring(@bitmap,1,1) & 128 when 128 then @c8 else [col7] end
where [Date] = @pkc1
if @@rowcount = 0
if @@microsoftversion>0x07320000
exec sp_MSreplraiserror 20598
end
end

GO


Thanks,
Go to Top of Page
   

- Advertisement -