Best way to sync SQL 2000 and 2005 databases - sql

I have a production database in SQL 2000 and a SQL 2005 instance will be installed in a new server. I would like to have an updated copy of one SQL 2000 database in my SQL 2005 at anytime.
What is the best way to implement database sync between this two SQL versions?

You can create an SSIS package to do this and schedule it as a job.
Or if this is development machine that you want to keep you can do all the development on the 2005 database in scripts kept in source control (which is of course what you should be doing), then you take the most recent backup, restore it to the database and run any change scripts you need.
Or use Red_gate's SQL data compare. It costs money but its worth it.

if "anytime" means you need the data to be updated as soon as it changes, i would think about triggering the tables on the 2000 server to mirror the operation on the 2005 server.
or, a DTS on the 2000 server might do the job, but i have no experience with those (they are also deprecated if i'm not mistaken).
or, some scheduled jobs might keep data in sync between the servers (but they'll be out of sync until the next job run)
hope this helps, myself i'd go with triggering since it's a "set and forget" approach.

Related

Is it possible to execute query to mirror database? (MS SQL Server 2012)

Is it possible to execute query to mirror database? Without stopping mirroring.
In database mirroring you can query the mirrored database only if you create snapshots of that database. In SQL Server 2012, database snapshot is an Enterprise feature.
https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2012/cc645993(v%3dsql.110)
If you run queries on the snapshot you'll lave to license it, and are a few things to consider, check link below.
https://learn.microsoft.com/en-us/sql/database-engine/database-mirroring/database-mirroring-and-database-snapshots-sql-server?view=sql-server-ver15
If you're willing to license Enterprise, you'd be better of implementing AlywasOn Availability Groups where you can have a readable secondary.

SQL Server migrating database performance what is better

Some background:
A customer has asked an Certified SQL Server Consultant for his opinion on migrating from sql server 2005 to sql server 2008.
One of his most important recommendations was not to use backup/restore but instead use the migration wizard to copy all the data into a new database.
He said that this would ensure that the inner structure of the database would be in an SQL 2008 format, and would ultimately result in better performance.
The Customer is skeptical about this because they cant find any writing, in white papers or otherwise to corroborate the consultants statement.
So they posed me this question:
Given an SQL Database, which originally started out on SQL Server 2000, and has migrated to newer versions of SQL Server using backup/restore. (and finally being on SQL Server 2005)
Would migrating to SQL Server 2008 using the Migration Wizard, and in effect copying all the raw data into a new database, result in better performance characteristics. Then if they would be using the Backup/Restore method again?
I'll repeat what I posted on Twitter, "your consultant is an idiot".
Doing a backup and restore will be much easier, and require a much shorter downtime. Also it will ensure that the data is consistent and that no objects are missed.
So long as you are doing index maintenance (rebuilding or reorging/defragging indexes) then any page splits which have happened are fixed and there will be no performance problems.
When the database is moved from one version to another the physical database file is updated to the new version. You'll notice when you restore the database that the compatibility level is set to the old version's number. This has nothing to do with the physical structure of the database file. You can change the compatibility level at any time to a lower or higher version. You can see this if you restore the database using T-SQL as after the database is restored you'll see the specific upgrade steps which are performed.
In response to qwerty13579's comment, when the indexes are rebuild the index is written to new physical database pages so exporting and importing the data in a SQL Server database isn't needed.
For the record, the migration wizard is about the worst possible option for moving data from database to database.
I agree with Denny.
Backup/restore is the easiest way to upgrade.
For no downtime upgrade you can use database mirorring to new server and fail over to new version
One important task that improves performance is refreshing all statistics when you upgrade to a new version

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

How to move data in development database to production database since a date onwards?

I have an application which has two database servers: one is the development database server and the other one is a production database server. Accidentaly, a couple of months back I published the application for use and it was pointing towards the development database.
Since it was pointing to the development database, all the information inserted or restored went in to the development database.
I want to transfer the data which went into the development database from july to september to the production database.
Is there a way to do this?
Create an SSIS package that uses the development database as the source and the production database as the destination and run a query to pull the data from development into production.
By the way, we have had this happen to us once.
The big issue here is to identify what changed. If you have datetime stamps in all your tables, this should be fairly easy.
If you do not have date time stamps, you will have to compare data. So let's call your database ConsumerData. If you have a backup of the DEV environment from the day before the production instance of the app pointed to it, you can restore it as ConsumerDataNew.
There are multiple database comparison utilities (Redgate SQL Compare) that will let you compare tables across the databases (ConsumerData and ConsumerDataNew) and give out results as SQL statements that you can then run in Production.
You will, of course, have to identify which records in Dev were made by development ppl vs. which ones were made by the Production Application.
You can use DTSWizard to transfer data between two database. Write a SQL query to pull only the data you need.
Edit: I didn't realize it had fancy new name, SSIS.
Here's a good tutotrial for SQL Server 2005 Import / Export Wizard.
Red-Gate has a tool called SQL Compare to compare the schema and SQL Data compare to actually compare the data.
This might be helpful.

How can I replicate a table from SQL 2000 to SQL 2008?

I have a table on a SQL Server 2000 database, which I want copied verbatim to a 2008 server.
I tried to do it manually with INSERT/UPDATE triggers, but this technique runs in a distributed transaction, which does not work because I apparently have to enable MSDTC and the firewall; I don't want to do any of that.
Are there any other ways to replicate that table (in real-time) to the 2008 server?
My first question would be do you really need it to be replicated?
If you want to reference it real-time in Sql 2008, just do a linked server with a Synonym. This will make the table act like it is part of your schema, with minor limitations.
Have you tried to create a scheduled DTS/SSIS package to do the work?
Is it copying or replication? Copying implies a one-time action while replication implies an open-ended period of time during which these tables will be synchronized.