Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Transactional Replication

 
   Database Help (Home) -> Replication RSS
Next:  Trouble getting JDBCProxy Servlet to work  
Author Message
SATISH

External


Since: Nov 11, 2009
Posts: 1



(Msg. 1) Posted: Wed Nov 11, 2009 4:13 am
Post subject: Transactional Replication
Archived from groups: microsoft>public>sqlserver>replication (more info?)

I had 3 servers 2 transactional servers and one is main server
i.e., Multiple Publishers and Single Subscriber

A(TRANS SERVER)
B(TRANS SERVER)
C(MAIN SERVER)

I HAD CONFIGURED TRANSACTION REPLICATION

A TO C AND B TO C


In these servers i had taken one table(emp) for testing purpose
table:emp
Create table emp(empid int primary key identity(1,1),ename varchar(30),sal
decimal(18,2))

I had created emp table all the above 3 servers

Can you suggest me

HOW TO HANDLE IDENTITY VALUES WHEN TRANSACTION REPLICATION APPLIES

 >> Stay informed about: Transactional Replication 
Back to top
Login to vote
Hilary Cotter

External


Since: Jan 16, 2008
Posts: 143



(Msg. 2) Posted: Wed Nov 11, 2009 9:08 am
Post subject: Re: Transactional Replication [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

You have to do something like this.

Set Server A to have odd values, server B to have event values and
have an increment of 2.

Set up your article so that it does not drop the table is if exists
but rather to delete the data which matches the row filter.

Then set up an odd number row filter on Server A and even on Server B.

here is a sample.

use master
go
if exists (select name from sys.databases where name='ServerA')
begin
alter database ServerA set single_user with rollback immediate
drop database ServerA
create database ServerA
end
GO
if exists (select name from sys.databases where name='ServerB')
begin
alter database ServerB set single_user with rollback immediate
drop database ServerB
create database ServerB
end
GO
if exists (select name from sys.databases where name='ServerC')
begin
alter database ServerC set single_user with rollback immediate
drop database ServerC
create database ServerC
end
GO
use ServerA
GO
Create Table emp(empid int primary key identity(1,2) not for
replication ,ename varchar(30),sal decimal(18,2))
GO
declare @counter int
set @counter=1
while @counter<=1000
begin
insert into emp(ename, sal) values('test'+convert(char(4),
@counter),RAND()*100)
select @counter=@counter+1
end
use ServerB
GO
Create Table emp(empid int primary key identity(2,2) not for
replication ,ename varchar(30),sal decimal(18,2))
GO
declare @counter int
set @counter=1
while @counter<=1000
begin
insert into emp(ename, sal) values('test'+convert(char(4),
@counter),RAND()*100)
select @counter=@counter+1
end
Use ServerA
GO
sp_replicationdboption 'ServerA','Publish','True'
GO
sp_replicationdboption 'ServerB','Publish','True'
GO
sp_addpublication 'Test',@status='active'
GO
sp_addpublication_snapshot 'test'
GO
sp_addarticle 'Test', 'emp', @source_object = N'emp',
@pre_creation_cmd = N'delete', @schema_option = 0x000000000803509F,
@identityrangemanagementoption='manual',@filter_clause = N'empid %2=1'
GO
sp_addsubscription 'Test', 'ALL',@@ServerName, 'ServerC'
GO
sp_addpushsubscription_agent 'Test', @@ServerName, 'ServerC'
GO
exec distribution.dbo.sp_MSstartsnapshot_agent @@ServerName,
'ServerA','test'
GO
exec distribution.dbo.sp_MSstartdistribution_agent @@ServerName,
'ServerA','test',@@ServerName, 'ServerC'
GO
use ServerB
GO
sp_addpublication 'Test',@status='active'
GO
sp_addpublication_snapshot 'test'
GO
sp_addarticle 'Test', 'emp', @source_object = N'emp',
@pre_creation_cmd = N'delete', @schema_option = 0x000000000803509F,
@identityrangemanagementoption='manual',@filter_clause = N'empid %2=0'
GO
sp_addsubscription 'Test', 'ALL',@@ServerName, 'ServerC'
GO
sp_addpushsubscription_agent 'Test', @@ServerName, 'ServerC'
GO
exec distribution.dbo.sp_MSstartsnapshot_agent @@ServerName,
'ServerB','test'
GO
exec distribution.dbo.sp_MSstartdistribution_agent @@ServerName,
'ServerB','test',@@ServerName, 'ServerC'
GO
use ServerA
go
declare @counter int
set @counter=1
while @counter<=10
begin
insert into servera.dbo.emp(ename, sal) values('test'+convert(char(4),
@counter),RAND()*100)
insert into serverb.dbo.emp(ename, sal) values('test'+convert(char(4),
@counter),RAND()*100)
select @counter=@counter+1
end

 >> Stay informed about: Transactional Replication 
Back to top
Login to vote
Hilary Cotter3

External


Since: Aug 28, 2004
Posts: 458



(Msg. 3) Posted: Wed Nov 11, 2009 9:24 am
Post subject: Re: Transactional Replication [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

here is an example. Basically you have to seed your identity values with odd
or even values. Note that for servera I am using off values, and for serverb
I am using even.

I then set up my publication so that I will delete all data which matches
the row filter. I am filtering on odd values on server a and even values on
server b.

This way I don't need to do any schema chanages.


use master
go
if exists (select name from sys.databases where name='ServerA')
begin
alter database ServerA set single_user with rollback immediate
drop database ServerA
create database ServerA
end
GO
if exists (select name from sys.databases where name='ServerB')
begin
alter database ServerB set single_user with rollback immediate
drop database ServerB
create database ServerB
end
GO
if exists (select name from sys.databases where name='ServerC')
begin
alter database ServerC set single_user with rollback immediate
drop database ServerC
create database ServerC
end
GO
use ServerA
GO
Create Table emp(empid int primary key identity(1,2) not for replication
,ename varchar(30),sal decimal(18,2))
GO
declare @counter int
set @counter=1
while @counter<=1000
begin
insert into emp(ename, sal) values('test'+convert(char(4),
@counter),RAND()*100)
select @counter=@counter+1
end
use ServerB
GO
Create Table emp(empid int primary key identity(2,2) not for replication
,ename varchar(30),sal decimal(18,2))
GO
declare @counter int
set @counter=1
while @counter<=1000
begin
insert into emp(ename, sal) values('test'+convert(char(4),
@counter),RAND()*100)
select @counter=@counter+1
end
Use ServerA
GO
sp_replicationdboption 'ServerA','Publish','True'
GO
sp_replicationdboption 'ServerB','Publish','True'
GO
sp_addpublication 'Test',@status='active'
GO
sp_addpublication_snapshot 'test'
GO
sp_addarticle 'Test', 'emp', @source_object = N'emp', @pre_creation_cmd =
N'delete', @schema_option = 0x000000000803509F,
@identityrangemanagementoption='manual',@filter_clause = N'empid %2=1'
GO
sp_addsubscription 'Test', 'ALL',@@ServerName, 'ServerC'
GO
sp_addpushsubscription_agent 'Test', @@ServerName, 'ServerC'
GO
exec distribution.dbo.sp_MSstartsnapshot_agent @@ServerName,
'ServerA','test'
GO
exec distribution.dbo.sp_MSstartdistribution_agent @@ServerName,
'ServerA','test',@@ServerName, 'ServerC'
GO
use ServerB
GO
sp_addpublication 'Test',@status='active'
GO
sp_addpublication_snapshot 'test'
GO
sp_addarticle 'Test', 'emp', @source_object = N'emp', @pre_creation_cmd =
N'delete', @schema_option = 0x000000000803509F,
@identityrangemanagementoption='manual',@filter_clause = N'empid %2=0'
GO
sp_addsubscription 'Test', 'ALL',@@ServerName, 'ServerC'
GO
sp_addpushsubscription_agent 'Test', @@ServerName, 'ServerC'
GO
exec distribution.dbo.sp_MSstartsnapshot_agent @@ServerName,
'ServerB','test'
GO
exec distribution.dbo.sp_MSstartdistribution_agent @@ServerName,
'ServerB','test',@@ServerName, 'ServerC'
GO
use ServerA
go
declare @counter int
set @counter=1
while @counter<=10
begin
insert into servera.dbo.emp(ename, sal) values('test'+convert(char(4),
@counter),RAND()*100)
insert into serverb.dbo.emp(ename, sal) values('test'+convert(char(4),
@counter),RAND()*100)
select @counter=@counter+1
end


"SATISH" wrote in message

> I had 3 servers 2 transactional servers and one is main server
> i.e., Multiple Publishers and Single Subscriber
>
> A(TRANS SERVER)
> B(TRANS SERVER)
> C(MAIN SERVER)
>
> I HAD CONFIGURED TRANSACTION REPLICATION
>
> A TO C AND B TO C
>
>
> In these servers i had taken one table(emp) for testing purpose
> table:emp
> Create table emp(empid int primary key identity(1,1),ename varchar(30),sal
> decimal(18,2))
>
> I had created emp table all the above 3 servers
>
> Can you suggest me
>
> HOW TO HANDLE IDENTITY VALUES WHEN TRANSACTION REPLICATION APPLIES
>
 >> Stay informed about: Transactional Replication 
Back to top
Login to vote
Paul Ibison

External


Since: Nov 21, 2009
Posts: 4



(Msg. 4) Posted: Sat Nov 21, 2009 10:25 am
Post subject: Re: Transactional Replication [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I would probably change this to use a composite primary key. One part of the
composite key will refer to the originating publisher. That way you don't
need to bother about conflicting identity ranges, especially if you want to
add more subscribers at some later stage.
HTH,
Paul Ibison
 >> Stay informed about: Transactional Replication 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Combining Transactional Replication and Merge Replication - I would like to know if this scenario is possible: I have main database (Server A) that I replicate to another server using transactional replication (Server B), know I would like to publish this database on Server B as a merge publication and then...

Can you have transactional replication of blobs? - I am having an issue using transactional replication on a SQL 2005 SP2 system when trying to replicate an Image data type. The data won't write to the Prod system, let alone replicate. However, when I remove the table from the publication everything..

Bidirectional Transactional replication - Hi All Do any one know where to get good Knowledge resources for writing and implementing stored procedures for bidirectional transactional replication. I f any body has one implemented recently can you spare the steps involved and the best practises....

UDFs & Transactional Replication - I created a UDF... create FUNCTION dbo.WhatLocationIsThis() RETURNS numeric AS begin declare @return as numeric SELECT @return = Location FROM storemain..tblLocationTable return @return end GO When I run 'select dbo.WhatLocationIsThis()' it..

Schema changes screw up transactional replication - Hi We have two servers with SQL Server 2005, version 9.0.3042 on both. There is a transactional replication between them but when we make schema changes on the publisher something goes wrong. We get this error message Subquery returned more than 1..
   Database Help (Home) -> Replication All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]