REPLICATION FROM INFORMIX 10 TO SQL SERVER 2005

Sep 8, 2005

HI..

View 1 Replies


ADVERTISEMENT

Replication Between SQL Server Database And Linked Informix Server

Apr 19, 2004

I need help setting up replication between my SQL Server (data warehouse) database and a linked informix database.

Does anyone know the best to accomplish this. I can provide any additional information you require to help you, help me ;-)

View 4 Replies View Related

SSIS Help Loading From Sql Server 2005 To Informix 7.3.1 SE

May 16, 2008

HI

I am transferring the data from sql server 2005 to Informix 7.3.1 SE using SSIS .

I am using the OLEDB data connection for both source as well as destination databases.

I am trying to mapping the source and destination tables .I am getting the following error.


TITLE: Microsoft Visual Studio
------------------------------
Error at Data Flow Task [OLE DB Destination [184]]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E21.
Error at Data Flow Task [OLE DB Destination [184]]: Opening a rowset for ""srinivas"."company"" failed. Check that the object exists in the database.

------------------------------
ADDITIONAL INFORMATION:
Exception from HRESULT: 0xC02020E8 (Microsoft.SqlServer.DTSPipelineWrap)
------------------------------
BUTTONS:
OK
------------------------------


I am using the following ODBC driver for the connecting INFORMIX 7.3.1 which is running on LINUX environment.
Openlink Generic ODBC Driver

It's creates the table in the informix 7.3.1 but it's not mapping the source and destination databases columns.

Please help me any one. it's urgent .


Thanks,
Srinivas Unnam

View 3 Replies View Related

Connection Problem To Informix From SQL Server 2005 With Unicode Data

Dec 5, 2007

I have Informix 9.4TC6 and SQL Server 2005.DB_LOCALE in Informix DB is en_US.utf8 (en_US.57372).First, I created DSN to Informix. Then tried to get data with WinSqltool and it works fine.But when I created linked server in SQL Server 2005 I have problemswith languages other than English.I get a string like:è 'å· åŒ-å|å·¥æ¥æ ªå1/4 ä1/4šç¤3/4It seems to me that SQL Server splits 2-byte characters in 2 1-bytecharacters.If in options of linked server we set Collation Name to exactlanguagewe want --then string data will be correct (of course only oflanguage that we choose).Do you have any suggestions?????????P.S. I don't want to use SSIS (DTS) for extraction from Informix DB

View 1 Replies View Related

INFORMIX SQL To SQL 2005

Mar 18, 2008

My task is to convert this Informix SQl Script to SQL 2005, unfortunately I am not really familiar with Informix SQL. Below is an example script. I can figure out the "Select" statement and the "Where" statement, but the "From" statement is giving me a hard time. Any assistance would be appreciated.Thanks

set explain on;
UNLOAD TO '/export/home/permit/propinact.txt'
SELECT distinct property.parcel_number,
property.id,
property.eff_from_date,
property.eff_to_date,
property.situs_address_id,
legal_lines.legal_desc_line,
tax_code_area.tca_number,
usecd.value,
ct.code_description,
property_char.value,
property.property_status_cd,
legal_description.section,
legal_description.township,
legal_description.range,
property.pact_code

FROM property,
OUTER (legal_description, legal_lines),
outer property_char,
outer (property_char usecd, code_table ct),
tax_code_area,
prop_valuation

WHERE property.id = prop_valuation.property_id
AND property.id = legal_description.property_id
AND property.eff_to_date <= TODAY
AND legal_description.id = legal_lines.legal_id
AND legal_lines.line_nr = 1
AND tax_code_area.id = prop_valuation.tca_id
AND property.id = property_char.property_id
AND property_char.prop_char_typ_code = "SIZE"
AND property.id = usecd.property_id
AND usecd.prop_char_typ_code = "USECD"
AND usecd.value = ct.code_table_cd
AND property.pact_code <> 'PERS'

ORDER BY id

View 2 Replies View Related

URGENT.. REPLICATE FROM SQL 2005 TO INFORMIX 10

Nov 7, 2005

Hi.

View 1 Replies View Related

Need To Link Table In SQL Express 2005 From Informix/Access

Apr 5, 2007

Hi,



Can someone help me and advise steps how to create link through ODBC between SQL Express 2005 & Informix ODBC / Access Database



Thanks

Amir

View 1 Replies View Related

Execute Store Procedure In Informix From Sql Task Integration Services 2005

Dec 21, 2007



hi,
i need execute a store procedure of Informix from sql server integration services.
i use driver IBM informix provider 3.2 and have linked server Informix and use sql task for execute the procedure
it's posible??

View 2 Replies View Related

SQL 2005 Server (SP2) To SQL 2005 Express (SP2) Replication Looping/Excessive Repl Times

Sep 25, 2007

We have a large number of clients attempting to replicate two publications on 2005 Express databases (2 publications subscribed to the one subscriber database) with our 2005 Server (9.00.3042.00 SP2 Standard Edition) and experiencing two significant problems:

1) Users experience the following message:

The Merge Agent failed after detecting that retention-based metadata cleanup has deleted metadata at the Subscriber for changes not yet sent to the Publisher. You must reinitialize the subscription (without upload).

This problem should not apparently occur with SQL Server 2005 (or 2005 Express) instances with SP2 applied. All clients experiencing this problem have SP2 installed as does our Server and the retention period is 30 days. The subscribers have been replicating well under that.


2) Replications never succeed after appearing to replicate/loop around for hours

This issue is the most critical as we have clients who have been installed and re-installed with new instances of SQL Server 2005 Express, new empty databases (on subscriber before snapshot extraction), and using fresh snapshots (less than an few hours old) which cannot successfully replicate.

Interestingly there is at least 1 instance where several computers are subscribed and successfully replicating the same database as another where replication refuses to succeed.

To test we have taken a republished database from another 2005 Server which is working fine and restored it to the same server as the one holding the database with which we are experiencing problems and subscribed to it. This test worked fine and replication of both publications went through fast and repeatedly without showing any signs of problem.

This indicates that the problem is perhaps data related as it appears localised to that database.

Below are two screenshots which may assist.

Screenshot 1 Shows that on the server side the replication attempts look like they are succeeding despite the fact that the subscriber end does not indicate success. Also the history indicates the the subscription has spent all it's time initialising and not merging any changes.

Screenshot 2 Shows a rogue process which has appears on many of the problem child subscribers. It shows a process running with no end time even though the job indicates failure in the message and even though other replication attempts appear to have succeeded after it. This process stays in the history showing that it is running even when I can find no corresponding process for it.

Can anyone suggest a further course of action/further testing/further information required which may assist?

This is extremely urgent and any assistance would be greatly appreciated!

Thanks in advance!

Scott

View 5 Replies View Related

How Do I Measure Bandwith Usage For Merge Replication SQL 2005 To Sql Server Mobile 2005?

Jan 24, 2007

Hi,

Is there any way to measure bandwith usage during merge replication between sql server 2005 and sql server mobile 2005 running on a cradled wm5 mobile device.

Attaching the windows performance monitor to the network connection established over usb would work although I was wondering if there was something specific for this case integrated into Sql server 2005 / sql server mobile 2005 / Sql server management studio / third party tools that i could use ?

thnx,

pdns.

View 4 Replies View Related

Merge Replication - SQL Server 2005, Windows Vista And MSVisual Studio 2005

Jul 11, 2007

Hello everybody!

I hope that someone could help me.

I have a problem when i start sincronyzing with the emulator of MSVS2005 to SQL2005 in Windows Vista. I have the same program in the emulator, but sincronyzing with windows XP Pro and no problem...



I configure the connection to use the IUSR.



The source code that i use:



repl.InternetUrl = @"http://laptop/SQLMobileIIS/sqlcesa30.dll";

repl.Publisher = @"laptop";

repl.PublisherDatabase = @"database";

repl.PublisherSecurityMode = SecurityType.NTAuthentication;

repl.Publication = @"Pubdatabase";

repl.Subscriber = @"SQLMobile";

repl.SubscriberConnectionString = @"Data Source='" + nomeFicheiroBD + "';Password='3409'";



The error that returns is:



"Failure to connect to SQLServer with provided connection information. SQL Server does not exist, access is denied because the IIS user is not a valid user on the SQL Server, or the password is incorrect"



Does anybody knows what i can do?

HELP I NEED SOMEBODY TO HELP!

Thanks!

View 1 Replies View Related

Help Needed In Merge Replication, SQL Server 2005 Mobile Edition And VC# 2005

Apr 10, 2008

I have written following code in my application

I just want to display all the data of a Single table into a Data Grid, I know that we can drag and drop the table on to a form and datagrid is generated, but here I want to retrive those values through my code, how should i do that

I am getting following errors while running the program
Error 1) Error No. 28037, MS SQL Server 2005 Evrywhere Edition
Error: A request to send data to the computer running IIS has failed. For more information see HRESULT
Error 2) Error No. 0, SQL Server 2005 Evrywhere Edition ADO.Net Data Provider
Error: The specified table does not exist [ JobLists ].

Can anybody please tell me, where I went wrong ??? In this code anywhere else????

Note: While adding a Data Source of SQL Server 2005 Mobile Edition, I have added that .sdf file into my project, thats why I have written the Data Source as : .DbFile.sdf



@"Data Source = .DbDotNetCF.sdf";


The code is as follows:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;

namespace DeviceApplication1
{
public partial class Form1 : Form
{
string filename = @".DbDotNetCF.sdf";

private DataSet dsJobLists;

public Form1()
{
InitializeComponent();
}

private void DeleteDB()
{
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
}

private void Sync()
{
SqlCeReplication repl = new SqlCeReplication();

repl.InternetUrl = @"http://localhost/WebsiteDotNetCF/sqlcesa30.dll";
repl.Publisher = @"RAHU";
repl.PublisherDatabase = @"DotNetCF";
repl.PublisherSecurityMode = SecurityType.NTAuthentication;
repl.Publication = @"PubDotNetCF";
repl.Subscriber = @"SubDotNetCF";
repl.SubscriberConnectionString = @"Data Source='" + filename + "';Max Database Size=128;Default Lock Escalation =100;";
try
{
if (!System.IO.File.Exists(filename))
{
repl.AddSubscription(AddOption.CreateDatabase);
}
repl.Synchronize();
}
catch (SqlCeException ex)
{
DisplaySQLCEErrors(ex);
}
finally
{
repl.Dispose();
}


// Display Same Data In Another DataGrid : dataGrid1
SqlCeConnection cn = new SqlCeConnection(@"Data Source='" + filename + "'");

SqlCeDataAdapter daJobLists = new SqlCeDataAdapter("SELECT JobListsID, JobID, PersonID FROM JobLists", cn);
if (dsJobLists == null)
{
dsJobLists = new DataSet();
}
try
{
dsJobLists.Clear();
daJobLists.Fill(dsJobLists, "JobLists");
dataGrid1.DataSource = dsJobLists.Tables["JobLists"];
}
catch (SqlCeException ex)
{
DisplaySQLCEErrors(ex);
}
}

private void DisplaySQLCEErrors(SqlCeException ex)
{
for (int i = 0; i < ex.Errors.Count; i++)
{
MessageBox.Show("Index #" + i.ToString() + ""
+ ex.Errors.Source + ""
+ "Error: " + ex.Errors.Message,
"Error No. " + ex.Errors.NativeError.ToString());
}
}

private void Form1_Load(object sender, EventArgs e)
{
Sync();
DeleteDB();

if (DbDotNetCFDataSetUtil.DesignerUtil.IsRunTime())
{
// TODO: Delete this line of code to remove the default AutoFill for 'dbDotNetCFDataSet.JobLists'.
this.jobListsTableAdapter.Fill(this.dbDotNetCFDataSet.JobLists);
}
}
}
}



I have created a merge replication correctlly( I suppose, there were no errros)
Please help

Your help will be appriciated

View 1 Replies View Related

Informix------SQL Server.....URGENT

Feb 21, 2000

Hi ,
I am an Informix user who has shifted to SQL Server,,,,I just wanted to know the equivalent of 'ISOLATION TO DIRTY READ' as in Informix in SQL SERVER....

Thanks,
Visitor

View 1 Replies View Related

Need A Way To Port From Informix To Sql Server

Jan 5, 2001

Hi,

Could anyone tell me how the data can be ported from informix to sql server ?

Is there a way to run the informix query from sql server ?

Thanks,
Vijay.

View 1 Replies View Related

SQL Server Versus Informix

Oct 25, 2000

Hi all,

Anyone here ever used the Informix database and can give me some differences between Informix and SQL.

One of our users is thinking about purchasing a COTS product that only supports an Informix database. I need to convince the user to evaluate other rival applications that can support SQL and need some arguments in favor of not going with Informix.

Any ideas appreciated,
Faustina

View 6 Replies View Related

Link Informix To SQL Server

Oct 6, 2006

Hi,

I am considdering to link a Informix database (running on SCO Unix) to a SQL Server 2005. Only problem is ... I have no idea how to do this! The reason I'm attempring this is to try and see if it would fix a problem I'm experiencing when using Reporting Services to generate reports from a Informix data source. I've been told that setting up a linked server might fix the problem. If anyone could perhabs guide me through setting up the linked server I would be very grateful! The ODBC credentials for setting up a connection to the Informix DB as follows:

Servername : pal_tli
Hostname : server_name
Service : pal_ser
Protocal : sesoctcp
Database : db_name
Username : user_name
Password : pword

:confused:

View 1 Replies View Related

Connecting To Informix Dtabase From SQL Server

Jun 14, 2001

Hi,
I want to know how to connect to informix from SQL server and how can I run queries for the tables in Informix from sql server.

Thanks
Arun

View 1 Replies View Related

Downloading Data From Our Informix Server

Jan 7, 2004

Our entire sales database sits on an Informix server and users run their reports directly to this server.

Because of the volume of data - upwards of 7 million rows in some tables we are finding performance is becoming an issue. We realise that Informix is not the best for running queries and so are looking to replicate to a SQL server and use that as a reporting server.

My chosen method is DTS using ODBC which works fine. However due to the sheer volume of data to be downloaded each night (over a 512K wan link) we only want to download changed data.

Is there any way we can get SQL2000 to download only change data - i.e a differential download or something? We don't have a unique field in the table (for whatever reason) such as sales date or transaction ID (shops might upload old / back-dated transactions for example due to a systems failure).

If I do have to download all the data every night is my method the most efficient or is there some other approach I could use?

Ultimatly the aim here is to relieve the Informix server of the reporting overhead so any alternative ideas are welcome!

Many thanks

View 2 Replies View Related

Transfering Data From Informix To Sql Server

Feb 6, 2004

I need to transfer seven tables from Informix DB to SQL Server every night. Any suggestions for the best way of doing it? Is DTS the best way? How about through replication?

Thanks in advance.

View 1 Replies View Related

Linking Informix Database To Sql Server

Sep 7, 2005

Can anyone halp me with this?

I want to link/access informix database to Sql Server stored procedure.

View 12 Replies View Related

Integration Of SQL Server With Cache DB, Informix

Mar 12, 2008

we r doing some application and SQL server as backend DB Server. this sql server has to be updated continiously 24*7 with data from 3 external sources Cache DB, Iformix and Oracle DB servers. How to handle this in such away that all changes at 3 external sources to be updated to SQL server and this data will use by our application at frondend.
we though of ODBC., but ODBC is very very slow. It should lke Shadowing.
How to handle this?. any help will greatly appreciated.

View 2 Replies View Related

Informix To SQL Server Stored Procedure Tool

Oct 6, 2005

Does anyone know where to get a migration tool for porting Informix stored procedures to SQL Server? I'm not looking forward to hand migrating 111 stored procedures. I can't find a migration tool on the net. :eek:

Thanks for any tips.

View 1 Replies View Related

Integration Of SQL Server With Cache DB, Informix And Oracle

Mar 12, 2008

SUB: pushing data to SQL server from Informix, Oracle and Cache DB


we r doing some application and SQL server as backend DB Server. this sql server has to be updated continiously 24*7 with data from 3 external sources Cache DB, Iformix and Oracle DB servers. How to handle this in such away that all changes at 3 external sources to be updated to SQL server and this data will use by our application at frondend.
we though of ODBC., but ODBC is very very slow. It should lke Shadowing.
How to handle this?. any help will greatly appreciated.

Thanks in advance.

Prasad
vsrprasad16@gmail.com

View 1 Replies View Related

Import Tables From Informix To Sql Server 2000

Jun 20, 2007

hi all ,

i need to import some tables from Infomix database to the sql server 2000.
what is the easiest way to do it as im quite new at this area.
thanks
linda

View 4 Replies View Related

Integration Of SQL Server With Cache DB, Informix And Oracle

Mar 12, 2008



we r doing some application and SQL server as backend DB Server. this sql server has to be updated continiously 24*7 with data from 3 external sources Cache DB, Iformix and Oracle DB servers. How to handle this in such away that all changes at 3 external sources to be updated to SQL server and this data will use by our application at frondend.
we though of ODBC., but ODBC is very very slow. It should lke Shadowing.
How to handle this?. any help will greatly appreciated.

Thanks in advance.

Prasad
vsrprasad16@gmail.com

View 1 Replies View Related

Queries Against Linked Server To Informix Via ODBC Errors

Oct 9, 2007

What can be the reason(s) why I can't get data from a linked server using an ODBC datasource that works fast & fine from MS Access?


I have an ODBC connection (System DSN) configured for an Informix ODBC driver.
The Test button (belonging to this driver-setup) reports a successfull connection test.
Getting data from this database by linking tables in MS Access works fast and easy.
But I have tried for many days now to setup a linked server from SQL Server (2005)
Creation goes fine, but as soon as I issue a query, (e.g. 'select * from infrem723...remotetable' or using 'openquery')
I get the following error:
---

Msg 7399, Level 16, State 1, Line 1

The OLE DB provider "MSDASQL" for linked server "infrem723" reported an error. The provider did not give any information about the error.

Msg 7303, Level 16, State 1, Line 1

Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "infrem723".

---

Why is Access able to read what "MSDASQL" cannot?
I am desperate - can anybody help?Thanks a lot!

View 8 Replies View Related

A Call To SQL Server Reconciler Failed. SQL Server 2005, SQL Server Mobile Merge Replication

Oct 2, 2005

Hi,

View 36 Replies View Related

RMO: Replication Between SQL Server 2005 Amd SQL Server 2005 Express

Sep 6, 2005

Hi!

View 14 Replies View Related

Replication In Sql Server 2005

Mar 16, 2007

Hi all,

I would like to know about "Replication in Sql Server 2005" in a step by step manner! would anybody help this out!

Thanks in anticipation

View 1 Replies View Related

How To Do Replication In SQL Server 2005

Aug 28, 2007

Hi,

I have two servers with sql server 2005, one is in the main office and the other in a store...

I would like that the items table from the main office send new data to the server at store, and the sales data from the store to be send to the main office, can anyone help me to do that?!

Thanks

View 3 Replies View Related

Setting Up Replication On SQL Server 2000 Using Distributor Running On SQL Server 2005

Jul 6, 2006

Hi

I have a setup where I need to replicate the database which is actually subscribing from another database. The current setup is all in SQL Server 2000. I need to now setup a Distrbutor on a SQL server 2005 and publish the database using this distributor to another server on SQL server 2000.



Has anybody done this before. If yes what will I need to check. Can you please let me know :-



1) SQL Server 2000 which SP should be installed to support this enviroment.

2) SQL Server 2005 which SP should be installed to support this environment.

3) Any thing that I need to look out for.



Thanks for any inputs on this.



Regards

View 3 Replies View Related

SQL Server 2005 Transaction Replication

May 11, 2007

We are implementing 2005 transaction replication on source database to target staging subscring database but we want to keep all transaction changes from source within staging subscribing tables.
If source column gets updated we want to keep old record and new updated record in staging subscriber. Transaction replication synchronizes but does not keep history on subscriber. Do we update stored proc's
anyone have examples of code or ideas??

View 20 Replies View Related

Bidirectional Replication In SQL Server 2005 SP2

Feb 25, 2008

Hi,

I have a problem configuring Bidirectional replication in SQL Server 2005 SP2. I configured Publication and Subscription on two different SQL 2005 instances on different machines (Station1SQL2005 and Station2SQL2005 respectively). Databases are DBTest1 in Station1 and DBTest2 in Station2. I have two tables one in DBTest1 and the other in DBTest2.

Script for the above configuration:

This below configuration does not work if i configure Publication and Subscription on the same machines

---*************************************************************************************************

For Station1:
IF EXISTS(SELECT * FROM sys.databases WHERE name = 'dbtest1')
DROP DATABASE dbtest1;

CREATE DATABASE dbtest1
go

--Create table named two_way_dbtest1 that have an IDENTITY column with the NOT FOR REPLICATION option set
USE dbtest1
go

IF EXISTS (SELECT * FROM sysobjects WHERE name LIKE 'two_way_dbtest1')
DROP TABLE two_way_dbtest1;
GO

CREATE TABLE two_way_dbtest1
(
pkcol INTEGER PRIMARY KEY NOT NULL,
intcol INTEGER IDENTITY(1,1) NOT FOR REPLICATION,
charcol CHAR(100),
timestampcol TIMESTAMP
)


/*Allocate a predetermined range of values to the primary key column
so that the values on the different servers are not in the same range.
For example, you can enforce 1-1000 as the key range for the two_way_dbtest1 table in the dbtest1 database,
and then enforce 1001 -2000 as the key range for two_way_dbtest2 table in the dbtest2 database.
To do so, use the following code:
*/
-- Constraint to enforce a range of values between 1 and 1000 in database dbtest1
USE dbtest1
go

ALTER TABLE
two_way_dbtest1
WITH NOCHECK
ADD CONSTRAINT
checkprimcol CHECK NOT FOR REPLICATION
(
pkcol BETWEEN 1 AND 1000
)
go


--Enable your server as the distributor, and then create a distribution database
--Ensure SQL Server Agent service is running before executing the below statement.
USE master
go
sp_adddistributor @distributor = 'Station1SQL2005'
go

--create a distribution database for the distributor
USE master
go
sp_adddistributiondb @database='distribution'
go

--Enable the computers running SQL Server that are participating in the replication as publishers
USE master
go

exec sp_adddistpublisher
@publisher = 'Station1SQL2005',
@distribution_db ='distribution',
@security_mode = 0,
@login = 'xxxxxxx',
@password = 'xxxxxxx',
@working_directory ='F:ReplicationReplication Working Directory'

--Enable the identified databases for replication
USE master
go

exec sp_replicationdboption N'dbtest1', N'publish', true
go

--Create the custom stored procedures in the dbtest1 database
USE dbtest1
go

-- INSERT Stored Procedure

CREATE PROCEDURE sp_ins_two_way_dbtest1
@pkcol int,
@intcol int,
@charcol char(100),
@timestampcol timestamp,
@rowidcol uniqueidentifier
AS
INSERT INTO two_way_dbtest1
(
pkcol,
intcol,
charcol
)
VALUES
(
@pkcol,
@intcol,
@charcol
)
go

--UPDATE Stored Procedure

CREATE PROCEDURE sp_upd_two_way_dbtest1
@pkcol int,
@intcol int,
@charcol char(100),
@timestampcol timestamp,
@rowidcol uniqueidentifier,
@old_pkcol int
as
DECLARE @x int
DECLARE @y int
DECLARE @z char(100)

SELECT
@x=pkcol,
@y=intcol,
@z=charcol
FROM
two_way_dbtest1
WHERE
pkcol = @pkcol



DELETE
two_way_dbtest1
WHERE
pkcol=@pkcol



INSERT INTO two_way_dbtest1
(
pkcol,
intcol,
charcol
)
VALUES
(
CASE ISNULL(@pkcol,0) WHEN 0 THEN @x ELSE @pkcol END,
CASE ISNULL(@intcol,0) WHEN 0 THEN @y ELSE @intcol END,
CASE ISNULL(@charcol,'N') WHEN 'N' THEN @z ELSE @charcol END
)
go

-- DELETE Stored Procedure

CREATE PROCEDURE sp_del_two_way_dbtest1
@old_pkcol int
AS
DELETE
two_way_dbtest1
WHERE
pkcol = @old_pkcol
go

--Create a transactional publication, and then add articles to the publication in both the dbtest1 and the dbtest2 databases
--In the database dbtest1.
USE dbtest1
go

-- Adding the transactional publication.
EXEC sp_addpublication
@publication = N'two_way_pub_dbtest1',
@restricted = N'false',
@sync_method = N'native',
@repl_freq = N'continuous',
@description = N'Transactional publication for database dbtest1.',
@status = N'active',
@allow_push = N'true',
@allow_pull = N'true',
@allow_anonymous = N'false',
@enabled_for_internet = N'false',
@independent_agent = N'false',
@immediate_sync = N'false',
@allow_sync_tran = N'true',
@autogen_sync_procs = N'true',
--To avoid expiry if there are 5 continuous holidays for a company. If 0, well-known subscriptions
--to the publication will never expire and be removed by the Expired Subscription Cleanup Agent.
@retention = 120
go

EXEC sp_addpublication_snapshot
@publication = N'two_way_pub_dbtest1',
@frequency_type = 4,
@frequency_interval = 1,
@frequency_relative_interval = 0,
@frequency_recurrence_factor = 1,
@frequency_subday = 2,
@frequency_subday_interval = 10,
@active_start_date = 20080225,
@active_end_date = 99991231,
@active_start_time_of_day = 070000,
@active_end_time_of_day = 235959
go

-- Adding the transactional articles.
EXEC sp_addarticle
@publication = N'two_way_pub_dbtest1',
@article = N'two_way_dbtest1',
@source_owner = N'dbo',
@source_object = N'two_way_dbtest1',
@destination_table = N'two_way_dbtest2',
@type = N'logbased',
@creation_script = null,
@description = 'two_way_dbtest1 table data will be replicated to two_way_dbtest2',
@pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F1,
@status = 16,
@vertical_partition = N'false',
@ins_cmd = N'CALL sp_ins_two_way_dbtest1',
@del_cmd = N'CALL sp_del_two_way_dbtest1',
@upd_cmd = N'CALL sp_upd_two_way_dbtest1',
@filter = null,
@sync_object = null,
@identityrangemanagementoption = 'manual'
go

/*In this scenario, the dbtest1 database is the central subscriber.
Create transactional subscriptions in the dbtest2 database that subscribe to the publication at dbtest1
and in the dbtest1 database that subscribe to the publication at dbtest2
*/
--Create all the subscriptions with the LOOPBACK_DETECTION option enabled
--Adding the transactional subscription in dbtest1.
USE dbtest1
go
EXEC sp_addsubscription
@publication = N'two_way_pub_dbtest1',
@article = N'all',
@subscriber = 'Station2SQL2005',
@destination_db = N'dbtest2',
@sync_type = N'none',
@status = N'active',
@update_mode = N'sync tran',
@loopback_detection = 'true'
go

EXEC sp_addpushsubscription_agent
@publication = N'two_way_pub_dbtest1',
@subscriber = 'Station2SQL2005',
@subscriber_db = N'dbtest2'
go

For Station2:
--Create database named test1
IF EXISTS(SELECT * FROM sys.databases WHERE name = 'dbtest2')
DROP DATABASE dbtest2
go

CREATE DATABASE dbtest2
go

--Create table named two_way_dbtest1 that have an IDENTITY column with the NOT FOR REPLICATION option set
USE dbtest2
go

IF EXISTS (SELECT * FROM sysobjects WHERE name LIKE 'two_way_dbtest2')
DROP TABLE two_way_dbtest2;
GO

CREATE TABLE two_way_dbtest2
(
pkcol INTEGER PRIMARY KEY NOT NULL,
intcol INTEGER IDENTITY(1,1) NOT FOR REPLICATION,
charcol CHAR(100),
timestampcol TIMESTAMP
)


/*Allocate a predetermined range of values to the primary key column
so that the values on the different servers are not in the same range.
For example, you can enforce 1-1000 as the key range for the two_way_dbtest1 table in the dbtest1 database,
and then enforce 1001 -2000 as the key range for two_way_dbtest2 table in the dbtest2 database.
To do so, use the following code:
*/
-- Constraint to enforce a range of values between 1 and 1000 in database dbtest1
USE dbtest2
go

ALTER TABLE
two_way_dbtest2
WITH NOCHECK
ADD CONSTRAINT
checkprimcol CHECK NOT FOR REPLICATION
(
pkcol BETWEEN 1 AND 1000
)
go


--Enable your server as the distributor, and then create a distribution database
--Ensure SQL Server Agent service is running before executing the below statement.
USE master
go
EXEC sp_adddistributor
@distributor = 'Station2SQL2005'
go

--create a distribution database for the distributor
USE master
go
sp_adddistributiondb @database='distribution'
go

--Enable the computers running SQL Server that are participating in the replication as publishers
USE master
go

exec sp_adddistpublisher
@publisher = 'Station2SQL2005',
@distribution_db ='distribution',
@security_mode = 0,
@login = 'xxxxxxxxx',
@password = 'xxxxxxx',
@working_directory ='E:ReplicationWorking Directory'

--Enable the identified databases for replication
USE master
go

exec sp_replicationdboption N'dbtest2', N'publish', true
go

--Create the custom stored procedures in the dbtest1 database
USE dbtest2
go

-- INSERT Stored Procedure

CREATE PROCEDURE sp_ins_two_way_dbtest2
@pkcol int,
@intcol int,
@charcol char(100),
@timestampcol timestamp,
@rowidcol uniqueidentifier
AS
INSERT INTO two_way_dbtest2
(
pkcol,
intcol,
charcol
)
VALUES
(
@pkcol,
@intcol,
@charcol
)
go

--UPDATE Stored Procedure

CREATE PROCEDURE sp_upd_two_way_dbtest2
@pkcol int,
@intcol int,
@charcol char(100),
@timestampcol timestamp,
@rowidcol uniqueidentifier,
@old_pkcol int
as
DECLARE @x int
DECLARE @y int
DECLARE @z char(100)

SELECT
@x=pkcol,
@y=intcol,
@z=charcol
FROM
two_way_dbtest2
WHERE
pkcol = @pkcol



DELETE
two_way_dbtest2
WHERE
pkcol=@pkcol



INSERT INTO two_way_dbtest2
(
pkcol,
intcol,
charcol
)
VALUES
(
CASE ISNULL(@pkcol,0) WHEN 0 THEN @x ELSE @pkcol END,
CASE ISNULL(@intcol,0) WHEN 0 THEN @y ELSE @intcol END,
CASE ISNULL(@charcol,'N') WHEN 'N' THEN @z ELSE @charcol END
)
go

-- DELETE Stored Procedure

CREATE PROCEDURE sp_del_two_way_dbtest2
@old_pkcol int
AS
DELETE
two_way_dbtest2
WHERE
pkcol = @old_pkcol
go

--Create a transactional publication, and then add articles to the publication in both the dbtest1 and the dbtest2 databases
--In the database dbtest1.
USE dbtest2
go

-- Adding the transactional publication.
EXEC sp_addpublication
@publication = N'two_way_pub_dbtest2',
@restricted = N'false',
@sync_method = N'native',
@repl_freq = N'continuous',
@description = N'Transactional publication for database dbtest2.',
@status = N'active',
@allow_push = N'true',
@allow_pull = N'true',
@allow_anonymous = N'false',
@enabled_for_internet = N'false',
@independent_agent = N'false',
@immediate_sync = N'false',
@allow_sync_tran = N'true',
@autogen_sync_procs = N'true',
--To avoid expiry if there are 5 continuous holidays for a company. If 0, well-known subscriptions
--to the publication will never expire and be removed by the Expired Subscription Cleanup Agent.
@retention = 120
go

EXEC sp_addpublication_snapshot
@publication = N'two_way_pub_dbtest2',
@frequency_type = 4,
@frequency_interval = 1,
@frequency_relative_interval = 0,
@frequency_recurrence_factor = 1,
@frequency_subday = 2,
@frequency_subday_interval = 10,
@active_start_date = 20080225,
@active_end_date = 99991231,
@active_start_time_of_day = 070000,
@active_end_time_of_day = 235959
go

-- Adding the transactional articles.
EXEC sp_addarticle
@publication = N'two_way_pub_dbtest2',
@article = N'two_way_dbtest2',
@source_owner = N'dbo',
@source_object = N'two_way_dbtest2',
@destination_table = N'two_way_dbtest1',
@type = N'logbased',
@creation_script = null,
@description = 'two_way_dbtest2 table data will be replicated to two_way_dbtest1',
@pre_creation_cmd = N'drop',
@schema_option = 0x00000000000000F1,
@status = 16,
@vertical_partition = N'false',
@ins_cmd = N'CALL sp_ins_two_way_dbtest2',
@del_cmd = N'CALL sp_del_two_way_dbtest2',
@upd_cmd = N'CALL sp_upd_two_way_dbtest2',
@filter = null,
@sync_object = null,
@identityrangemanagementoption = 'manual'
go

/*In this scenario, the dbtest1 database is the central subscriber.
Create transactional subscriptions in the dbtest2 database that subscribe to the publication at dbtest1
and in the dbtest1 database that subscribe to the publication at dbtest2
*/
--Create all the subscriptions with the LOOPBACK_DETECTION option enabled
--Adding the transactional subscription in dbtest1.
USE dbtest2
go
EXEC sp_addsubscription
@publication = N'two_way_pub_dbtest2',
@article = N'all',
@subscriber = 'Station1SQL2005',
@destination_db = N'dbtest1',
@sync_type = N'none',
@status = N'active',
@update_mode = N'sync tran',
@loopback_detection = 'true'
go

EXEC sp_addpushsubscription_agent
@publication = N'two_way_pub_dbtest2',
@subscriber = 'Station1SQL2005',
@subscriber_db = N'dbtest1'
go

---*************************************************************************************************
It would be grateful if somebody gives me a solution.

Thanks in advance.

Ravi.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved