I need to make structure changes to a database that is part of a subscription that is using Transactional Replication.
I am wondering if I take the Database out of the Article list, make the changes on the Master server then do a Snapshot to reinitialize the subscribers.
Will that work, or is there something else I should do to get this resolved.
I think SQL Server 2005 replicates schema changes as well. See http://technet.microsoft.com/en-us/library/ms151870.aspx
Related
I had a transactional replication in SQL server 2012. people changed the data inside the subscription database. so changes has been added to subscription from:
1- my publication
2- people who inserted their own data directly into subscription database.
I wana rebuild my replication, is there any way to rebuild replication using my subscription database which have users data?
Thanks,
Babak
The short answer is in the documentation under the subheading "Databases at the Subscriber".
But the longer answer is that you should design your replication topology in such a way so as to make the subscription database completely expendable. That is, if you have data that the users are entering directly into that database, either put it in separate tables (and put those tables on separate a separate filegroup) or, better, put those tables in a separate database completely and create views/synonyms to those tables in your subscriber database.
I would like to migrate few tables from one database server to other database server (both are SQL server). How can I do this? I have heard about SSIS package but never done this. I would like to understand this process in detail.
Source database is refreshed daily. what can I do to refresh my destination database to reflect the source database all the time.
Please help me, I would like to understand this process from beginning till end because I have never done this before.
Thanks,
Here are the high level steps.
Create an SSIS project. Use a data flow task for each table. Depending on your requirements you might be able to just clear the tables and just reload them.
Create a new sql agent job on the server to schedule the job. Make sure you schedule after the source database is completely loaded.
I'm working on automated tests for particular web app. It uses database to persist data (SQL Server in this case).
In our automated tests we perform several database changes (inserts, updates). And after tests have been executed we want to restore database to original state.
Steps will be something like this:
Create somehow backup
Execute tests
Restore data from backup
The first version was pretty simple - create table backup and then restore it. But we've encountered an issue with references integrity.
After that we decided to use full database backup, but I don't like this idea.
Also we were thinking that we can track all references and backup only needed tables not a whole database.
Last thoughts was about somehow logging our actions (inserts, updates) and then perform reverse actions (deletes for inserts, updates with old data for updates), but it looks kinda complicated.
May be there is another solution?
Actually, there is no need to restore the database in native SQL Server terms, nor to track the changes and then revert them back
You can use ApexSQL Restore – a SQL Server tool that attaches both native and natively compressed SQL database backups and transaction log backups as live databases, accessible via SQL Server Management Studio, Visual Studio or any other third-party tool. It allows attaching single or multiple full, differential and transaction log backups
For more information on how to use the tool in your scenario check the Using SQL database backups instead of live databases in a large development team online article
Disclaimer: I work as a Product Support Engineer at ApexSQL
If you wanting to do minimal changes to the database with Insert and Update, it is much better alternative to do those changes within transactions which can be rolled back at the end of the test. This way SQL server will automatically store information in regards what you changes and will reverse it back to state before test began.
BEGIN TRANSACTION http://technet.microsoft.com/en-us/library/ms188929.aspx
I think the better idea is to create test database.
You can also create Interface for methods, first implementation for real data (with real db) and the second one for test db.
You can create a database snapshot.
The snapshot will keep track of all changed data pages that are changed during your test. Once you are done, you can restore back form the snapshot to the previous state.
CREATE DATABASE [test_snaphot1] ON
( NAME = test, FILENAME =
'e:\SQLServer\Data\test_snapshot1.ss' )
AS SNAPSHOT OF [test];
GO
--do all your tests
RESTORE DATABASE [test] from
DATABASE_SNAPSHOT = 'test_snaphot1';
GO
You have to create a snapshot file for each datafile of your database. So if you have a database with 4 data files, then your snapshot syntax should include 4 snapshot files.
Found simple solution - renaming table.
Algorithm is pretty simple:
Rename table to another table, e.g. "table" to "table-backup" (references will refer to that backup table)
Create "table" from "table-backup" ("table" will not have any dependencies)
Perform any actions in the application
Drop "table" with dirty data (will not break references integrity)
Rename "table-backup" to "table" (references integrity will be kept).
Thanks
I am new to sql server .I have a sql server and I have 2nd sql server(backupserver).I want to copy data from sql server to 2nd one and all my transactions create update delete must be reflected in the 2nd server immediately in real time.I have very large data in my table assuming million of rows.How can I achieve this.I dont have previalge to use third party tools.
You specify that you need data to be reflected on the second server immediately, in real time.
This requirement will add latency to every transaction that occurs on your primary server, since every action will need to be committed on the secondary server before it can be committed on your primary server.
In addition to the latency, this requirement will also likely reduce your availability. If the secondary server is no longer able to successfully commit transactions from the primary, then the primary can no longer commit transactions either, and your system is down.
For more information about these constraints, refer to the extensive discussion around this topic(CAP theorem).
If you're OK with these restrictions, you might consider using Synchronous Database Mirroring (High-Safety Mode).
If you're not OK with these restrictions, please adjust / clarify your requirements.
You may try to get some help from these two references:
Replication in MS SQL Server
SQL Server Replication
On a side note an important thing you should need to plan before doing replication is the Replication model which you will use for your replication.
There is a list of Replication model which you can use:-
Peer-to-peer model
Central publisher model
Central publisher with remote distributor model
Central subscriber model
Publishing subscriber model
Each one of the above has its own advantages. Check them as per your need.
Also to add to it there are three types of Replication:-
Transactional replication
Merge replication
Snapshot replication
Check out this tutorial on SQL Server 2008 replication:
Tutorial: Replicating Data Between Continuously Connected Servers
Since you said "... reflected in the 2nd server immediately in real time", that means you want to use Transactional Replication. You still may only choose to replicate certain tables.
Does the "millions of rows" represent some kind of history? If so, consider the risks that Michael mentioned... and whether you need all the history in the 2nd server, or just current / recent activity. If it's just current/recent, it may be safer and less of a system drain, to write something in T-SQL or SSIS, for a job to execute that loops, reads, and copies the data.
That could be done with linked servers and triggers... but the risks Michael mentions, about preventing the primary server from committing transactions, are as much or more a concern with triggers... that you can avoid with your own T-SQL/SSIS + job.
Hope that helps...
I need to run the replication of one table in SQL Server 2005. Replication should be one way. From 1 master server to many children servers.
I thougt about snapshot replication, but I don't want to schedule it only for example every hour/minute ect. (I know how to do this.) but ALSO triggered it evry time new data appears in master server's table.
Is there a way to do it? Which type of replication should I use and how to configure it?
Can you use transactional replication?
http://msdn.microsoft.com/en-us/library/ms151176%28SQL.90%29.aspx