I have done replication on my SQL Server 2005 database.
Now i want to show the status from my GUI.(Can be C# or else)
Is there is any method or API by which i can monitor the status of replication.
This is for client confirmation that replication is working.
Thanks
Way something like this.
http://www.sqlmonster.com/Uwe/Forum.aspx/sql-server-replication/11698/How-to-get-the-replication-status-using-RMO-in
A great option is this: How to Programmatically Monitor Replication (via T-SQL):
http://msdn.microsoft.com/en-us/library/ms147874(SQL.90).aspx
And here's the SQL Server 2008 R2 version for anyone looking at this as well:
http://msdn.microsoft.com/en-us/library/ms147874(SQL.100).aspx
Using these special procedures can be a tiny bit of a pain from within T-SQL (as you'll commonly want to export their output into temp tables or table variables to 'filter it' an additional bit or what-not), but most devs will find this kind of interaction MUCH easier to deal with than using RMOs.
I like to use tracer tokens posted at regular intervals and then monitoring their status as they flow from publisher to distributor to subscriber. This can be done programatically with sp_posttracertoken at the publisher and checking the tracer token tables in the distributor. Hope this helps.
Monitoring Replication with Replication Monitor
Microsoft SQL Server Replication
Monitor is a graphical tool that
allows you to monitor the overall
health of a replication topology.
Replication Monitor provides detailed
information on the status and
performance of publications and
subscriptions...
How to: Start Replication Monitor (Replication Monitor)
Related
We have an Oracle OLTP system and a SQL Server reporting solution. We run nightly stored procedures to extract the data using linked server but it it very slow as it is transferring millions of records. It would be great to have some transactional replication to get this data into our SQL Server environment in a near real time manner for reporting purposes. Has anyone tried this? Without buying an expensive piece of software what would be the best bet?
We've looked into Apache Kafka to capture the changes and apply them to another database but it seems like a high maintenance approach.
If we switched on CDC on the Oracle side could we write a stored procedure to query the CDC table and make the changes?
Is there a simpler approach that we've overlooked?
We only have read access to the Oracle server but it is managed by a third party that could set up something on our behalf.
We have a transactional replication setup using 3 SQL Servers, 1st as publisher, 2nd as distributor, and 3rd as subscriber.
We have an activity to change the location of the replicated DB (subscriber) using de-attach and attach method. During this activity, I will need to stop the SQL server and hence all replicated transactions will fail.
What's the proper way to pause the replication during this activity, so when I attach the DB again and start the SQL service, replication will resume normally.
Thanks
Please see the following link for details of how to accomplish this:
Start and Stop a Replication Agent
The above article doesn't appear to give information on stopping the distribution agent, this can be achieved by using the stored procs detailed in the link below:
Start/Stop SQL Server Replication Agent using TSQL
I have 2 databases that have the same structure, one on a local machine and one on the company's server. Every determined amount of time, the data from the local DB should be synchronized to the server DB.
I have a general idea on how to do this - create a script that somehow "merges" the information that is not on the server DB, then make this script run as a scheduled job for the server. However, my problem lies in the fact that I am not very well experienced with this.
Does SQL Server Management Studio provide an easy way to do this (some kind of wizard) and generates this kind of script? Is this something I'll have to build from scratch?
I've done some basic google searches and came across the term 'Replication' but I don't fully understand it. I would rather hear some input from people who have actually done this or who are good with explaining this kind of stuff.
Thanks.
Replication sounds like a good option for this, but there would be some overhead (not technical overhead, but the knowledge need to support it).
Another SQL Server option is SSIS. SSIS provides graphical tools to design what you're trying to do. The SSIS package can also run SQL statements, if appropriate. An SSIS package can be started, and therefore scheduled, from a SQL Server job.
You should consider the complexity of the synchronization rules when choosing your solution. For example, would it be difficult to resolve conflicts, such as a duplicate key, when merging the data. A SQL script may be easy to create if the rules are simple. But, complex conflict rules may be more difficult to implement in a script (or, replication).
SQL Server Management Studio unfortunately doesn't offer much in this way.
You should have a serious look at some of the excellent commercial offerings out there:
Red Gate Software's SQL Compare and SQL Data Compare - excellent tools, highly recommended! You can even compare a live database against a backup from another database and synchronize the data - pretty nifty!
ApexSQL's SQL Diff and SQL Data Diff
They all cost money - but if you're serious about it, and you use them in your daily routine, they're paid for in no time at all - well worth every dime.
The only "free" option you have in SQL Server 2008 would be to create a link between the two servers and then use something like the MERGE statement (new in SQL Server 2008) to transfer the data. That doesn't work for structural changes, and it's limited only to having a live connection between the two servers.
You should definitely read up on transactional replication. It sounds like a good fit for the situation you've described. Here are a few links to get you started.
How Transactional Replication
Works
How do I... Configure
transactional replication between two
SQL Server 2005 systems?
Performance Tuning SQL Server
Transactional Replication
What you want is Peer-to-Peer Transactional Replication, which allows data to be updated at both databases yet keep them in sync through a contiguous merge of changes. This is the closes match to what you want, but is a fairly costly option (requires Enterprise Edition on both sites). Another option is Bidirectional Transactional Replication, but since this requires also two EE licenses, I say that peer-to-peer is easier to deploy for the same money.
A more budget friendly option is Updatable Subscriptions for Transactional Replication, but updatable subscriptions are being deprecated and you'd bet your money on a loosing horse.
Another option is to use Merge Replication. And finally, for the cases when the 'local' database is quite mobile there is Sync Framework.
Note that all these options require some configuration and cooperation from the Company's server DB.
There are some excellent third party tools out there. For me, xSQL Data Compare has always done the trick. And because the comparisons are highly modifiable it is suitable for almost every data compare or data-synchronization scenario. Hope this helps!
i have a security application that stores its data in a access database.now i'm required to
make a realtime synchronization (replication) between that access database and a new database in sql server 2005. these two database are the same.
any suggestion?!
i don't know how to do it using a windows service or not. i need exact technical answer.
Mostly, I would suggest you use a windows service to periodically check the MS Access db, and attempt to synchronize it with the Sql database.
This will allow you to remove the Human factor, and have this task run periodically to sync the dbs.
Have a look at
Creating a Basic Windows Service in
C#
Creating a Windows Service in C#
Also
Connect to Microsoft Access .mdb
database using C#
Beginners guide to accessing SQL
Server through C#
SQL server has built-in replication functionality that you get for free, so you don't need to worry about copying rows & tracking changes. There are several types of SQL replication that are used for different situations, such as merge replication, snapshot replication, and transactional replication. This last one, transactional replication sounds like what you want. Merge replication is used when you have users that might disconnect, go away and return later to synchronize (like remote users). Transactional replication is used where the subscribers and publisher are reliably connected. Snapshot replication generates a new snapshot each time synchronization occurs, and doesn't think about changes to the data. Read the MSDN documentation and find which of these types is appropriate for your situation.
Using these replication methods will require that you set up your tables in a SQL server or express instance - you can use that to synchronize with your SQL server and keep everything else Access as the front end. I think you want to follow astander's suggestion and use a windows service to trigger synchronization. However you can set up the Windows Synchronization Manager to automatically try to synchronize at startup, shutdown, when the computer is idle, etc. If you need finer control over triggering the synchronization then perhapse use a Windows app or service as astander suggested.
How can we find out that if a replication job or normal replication is running at a particular time. Please,help to figure out.
Assuming you are referring to Microsoft SQL Server Replication, here is a quick method to observe replication status.
In the database hosting the publication go to Object Explorer tree view:
1. Open Local Publications folder under Replication
2. Right Click on a publication select Log Reader Status
The log reader agent will be reading the transaction log and populating the distribution database with the changes that need to be pushed to subscriber.
An active log agent will show in the status window messages such as:
63 transactions with 439 command were delivered
Nevertheless, this diagram explains pretty quickly how the transactional replication works.
Replication Architecture (BOL: http://msdn.microsoft.com/en-us/library/ms151176.aspx)
In MS SQL if you need to programatically check a job status (for example from a monitoring tool) you can fire off the following query. For push replication the target would be the replication distributor (or the publisher if you haven't scaled out distribution). For pull replication the target would be the replication subscriber.
EXEC msdb..sp_help_job #job_name='<job name here>', #job_aspect = N'job'
You can find the job name under the SQL server agent for the distributor/subscriber.
You're looking for column 26 ("current_execution_status"), which will be "1" if the job is currently running.
In order to monitor replication you need to use the Replication Monitor tool.
The following article describes how to use this tool.
http://msdn.microsoft.com/en-us/library/ms151780(SQL.90).aspx
Cheers, John
sp_distcounters tells you the current status.
If the count of delivered commands changes for a given subscription then your replication is working, else not.