Clone SQL Server database - sql

I have two computers, one is the main used by people and the other is the backup in case the main stops working. They are both running SQL Server and at the moment whenever I want to sync their data I backup the main computer and restore the backup computer.
Is there an option to clone and on realtime if it's possible an sql server database on another computer running also SQL Server?
After a search I found about Transactional Replication is it what I'm looking for?

Currently, you have 3 options:
AlwaysOn
Database mirroring
Log shipping
Database mirroing is going to be deprecated in the future versions of SQL Server so perhaps you should choose between AlwaysOn and Log Shipping. Depends on what are your actual needs, you can read about differences and options here: https://msdn.microsoft.com/en-us/library/ms190202.aspx

Related

SQL Server 2008 R2 Developer and SQL Server 2008 Express Edition, Replication

I was looking for some advise on a current task and sifting though on the net I am not finding anything direct. I have full SQL Server 2008 in my central location and then 5 remote sites that use SQL Server 2008 Express for the database services. I am looking for a way to synch or replicate the databases in the 2008 Express instances back to my central 2008 developer edition instance.
What is blocking me is the editions and what is possible, I have been told log shipping and mirroring will not work with Express editions of SQL Server.
One thought was SSIS maybe from the central location pulling from the express instance, but again I don't know if this is possible.
Any ideas however big or small would be really appreciated!
Thanks!
Neither log shipping nor mirroring are replication solutions. They are high availability/disaster recovery solutions which allow you to have the same database in two (or more with log-sipping) locations. Only the source location can update the database.
What you want is replication, see Replicating Data to SQL Server Express. Merge Replication will allow you to update data at the periphery (on the SQL Express instances).
Note that all scenarios require static and available SQL Express instances. Replication will not work with if the SQL express instances are mobile (show up on the network with different names/IPs, think a laptop being moved around) or occasionally available (again, think a laptop that appears on and off the network as the user opens it in the corp WiFi or at home). For mobile/occasionally connected scenarios the right approach is Sync Framework.
One thought was SSIS maybe from the central location pulling from the express instance, but again I don't know if this is possible.
No, is not possible in practice, because of the impossibility of detecting changes ('what records need to be pulled?') and the lack of support for update conflict resolution.
Another approach, which I did see it deployed with success, is to use Service Broker since is freely available in Express. But it only solves the problem of transport (delivery the changes), and does not address detecting changes (usually solved via either app specific logic or via triggers) and applying the changes (this is not hard to solve though). Update conflicts are hard to handle.

How can we do Data Replication on SQL Server 2012 . For detail please read below

I have a database Now what I want If in any case my database server
has failed then it automatically gets data from another server. I want
to know how can we do Data Replication/Mirroring.
Can anybody share an idea how we can do this?
I have searched a lot in the Google but doesn't get exact link for the
Data Replication on SQL Server 2012. I really appreciate your
suggestions.
For failover type scenarios, you want to use either Mirroring or Always on, not replication.
Details on Mirroring are available here:
Database Mirroring
Details on Always On are available here:
SQL 2012 Always On
Both of these solutions are able to provide automatic failover for applications to a separate copy of the database if the primary server fails, AlwaysOn is the better solution (and mirroring is now apparently deprecated as of SQL 2012) but has some more complex requirements such as a dependency on windows clustering.
Documentation for SQL Server Replication can be found in Books Online for SQL Server 2012 - SQL Server Replication.

Is it possible to run replication on a SQL 2005 DB which is a mirrored principal server?

We have a client that currently has a large busy database that they back up using database mirroring. As part of a reporting requirement we need to use some of the data stored in the database to run reports against but we cannot access the data directly.
Is it possible for us to run transaction replication on that server to get our data while it is running database mirroring at the same time?
Thanks.
Yes it's possible to run transaction log shipping at the same time you are running mirroring. It is also possible to bring the secondary server up in a "Read Only" mode rather than "Standby" for the specific purpose of allowing you to run reports on the second server.

Sync two SQL Server databases

I have two databases: the source is a database from SQL Server Express by client and the target is a database from SQL Server 2005 database as backup initially. What I need is to sync the source to the target db if there is any difference between them and the sync is one-way from source to target.
I am not sure what tools are available. I tried to google this issue and found MS VS Team Edition (2005) has a tool to sync database, which can generate T-SQL scripts as well. Not sure if this one is good or not. Can I use the script as a scheduled job on SQL Server (target server)? By the way, I don't have Team Edition right now but I do have VS 2005 Prof. Any suggestions?
IMHO by far the easiest and fastest way to sync the two databases one-way (A to B) is to backup database on A and restore it on B. This could be done via T-SQL, let me know if you would like me to post SQL statements
Ideally you would set up Transactional Replication from your source to your target(s). However, since your source is Express edition and Replication does not work with Express as a publisher (source) but only as a subscriber (target), you cannot use it.
The best solution would be to upgrade your Express edition to SKU that supports Replication publishing (ie. Standard Edition).
Log shipping, or manual backup/restore, will not work because it will create an absolutely identical copy of the source db at the target, overwritting any changes made by the target (you mention 'some differences' may exist). Same goes for File/Copy.
SQL Compare tools are OK for a one time manual operation, but they fail at automated operations because they always compare the two databases from scratch, ei. are not capable of synching just what changed. As soon as data grows to a sufficient size, the comparison approach is doomed as it has to ship over the entire database for purpose of comparison alone.
Other solutions are to set up pro-active real-time ETL, but the time/cost investment into this is prohibitive compared with the cost of a SE license and deploying Replication.
Pay to play:
http://www.red-gate.com/products/SQL_Compare/index.htm
Free, open source:
http://www.codeplex.com/OpenDBiff
You should into the SQL Server tools produced by Red-Gate. I've found them to be the best around.
If you have SQL Server 05, you can use replication services(this comes with SQL Server). If you open up your management studio, under your server folders you should see one titled "Replication". From here you can setup subscriptions or publications with push or pull syncs.
Here's MSDN's take: http://msdn.microsoft.com/en-us/library/ms151198.aspx
If this is a one time / once-in-a-while thing, you can use SnapShot Replication.
If you need the databases to be in sync all the time, you can use Transactional Replication.
http://msdn.microsoft.com/en-us/library/ms151847.aspx
In addition to Red Gate tools you can try DB Ghost as well http://www.innovartis.co.uk/. It's most useful as a automated build tool, but does also have an user interface to diff and sync databases. It costs ~$350.00
USing microsoft sync framerok
http://msdn.microsoft.com/en-us/library/ee819079.aspx
http://msdn.microsoft.com/en-us/library/ff928525.aspx

Database Properties "Mirroring" Page

I am having a problem with one database on my SQL Server 2005 production server.
A number of databases are already set up for mirroring, however when I right click and go to properties in SSMS, on one particular database there is no "Mirroring" property page available.
I have done the normal tasks, such as setting Full Recovery model, running a full backup of the database and backing up the logs.
I can't see that this is a server specific issue as other databases are happily mirroring.
I've looked around and I can't see that I'm missing a setting, any help would be appreciated.
Thanks.
EDIT: This is nothing to do with the Mirror Database yet, I can't get as far as specifying the Mirror Database , I cannot see the "Mirroring" page on the principle.
EDIT: I have managed to setup mirroring using t-sql commands. However I am still unable to see the "Mirroring Page".
UPDATE: This applies to the Transaction Log Shipping option as well. I can successfully set it up in SQL but not through SSMS.
Check theese items:
2 . The mirror database has to be created from a full backup of the principal server and should be restored in "Restore with Norecovery" model. It is followed by a restore of transaction log backup of the principal database so that the log sequence numbers of the mirror and the principal database are in synch with each other.
3 . The mirror database must have the same name as the principal database.
...
8 . DB Mirroring is available in Enterprise, Developer and Standard Editions, however, please refer to Microsoft website for a comparison chart as some features are not available in the Standard Edition. SQL Server Workgroup and Express Editions can only be used as witness servers.
Database Mirroring in Microsoft SQL Server 2005
Test monitoring with sp_dbmmonitorresults (Transact-SQL)
I don't have the answer, but I ran across the same symptom yesterday, and I remembered your question here, hahaha. My problem was that I set up database mirroring using the wizards, but one of the systems had a firewall blocking the mirroring port. The wizard setup went all the way to the final part of enabling database mirroring, and then errored out - but at that point, mirroring was already set up. Mirroring worked great, but there was something in the database metadata that wasn't set quite right. Even when I removed the firewall, parts of SSMS acted as if mirroring wasn't set up for that particular database, even though it was.
I then set up additional databases for mirroring (with the firewall off) and they worked great. My solution was to remove mirroring on that database and then add it again, and it worked fine. Doesn't sound like that's worked for you, though.
I ended up having to have a Microsoft Support call for the problem I was facing. Anyway after sometime and a number of support sessions they worked out that the database with the problem had an ID of 4 in sys.databases. IDs 1-4 are usually reserved for the system databases and if a database has any of these ids the T-log or Mirroring properties are not displayed. So somehow our database got the ID 3 and now I better get on and detach and reattach some databases to reassign IDs.