I have the following questions about how transactional replication handles the following. For the sake of example, assume database 'A' is being replicated (via transactional replication) to database 'B'.
If a table in database ‘A’ is dropped, will the table get dropped in ‘B’?
If a table in ‘A’ is renamed, what happens to the table in ‘B’?
If we drop a column in a table in database ‘A’, what will happen to the column in the same table in database ‘B’?
If we rename a column in a table in database ‘A’, what will happen to the column in the same table in database ‘B’?
Is replicating stored procs, views and UDF’s are optional?
Is there any way to avoid all the stored process being created in database ‘B’ as a result of it being the subscriber of a replication?
a. If not, can we at least dictate what schema they are created in?
Most of your questions are answered here: Frequently asked questions for Replication Administrators
You cannot drop a table that is replicated. You have to first drop the article.
You cannot rename a table that is replicated. You have to first drop the article.
Issuing ALTER TABLE … DROP COLUMN at the Publisher, will result in the command being replicated to the Subscriber.
You cannot rename a column "whilst" it is being replicated. You need to remove it from replication first.
Yes, it's optional.
What do you mean by created?
All of these items can be tested very easily by creating a very simple Replication topology on a test server. I suggest you do so in order to both plan for and practice your changes.
Related
Can I implement symmetricDS in identical databases?
My scenerio
I have to databases:
Database A
Database B
Whatever data change happens in either one of them should reflect in the other:
Current situation:
Even though the DB are identical, database B have less tables that database A
Consider a table tableA from database A and same table in database B
But pk id for same records are actually different in two tables
Can i expand and implement symmetricDS if i want to expand to a third database
Currently i am using a mapping table and API to handle datasync.
Can i move to symmetricDS for syncing data
Yes, go ahead
SymemtricDs allows for bidirectional synchronization of databases
Only the tables of database B will be configured for synchronization. The extra tables from database A might be added to the mix using table transformation.
As long as there are constraints of uniqueness on columns in, for example, database A that are PKs in database B that will not be a problem.
You can add as many types and instances of those types of databases. Bear in mind that the graph of database relationships must satisfy the definition of a tree.
I am trying to move a table from one schema to another. I have tried this from table design and through TSQL with an ALTER SCHEMA statement (ALTER SCHEMA SchemaName TRANSFER dbo.ObjectName).
I can do this for any schema in my database except one now as it times out in the designer and runs forever in TSQL. It has 7-8 tables in it that I was originally able to put in the schema but now the schema appears locked. How do I debug this? I see nothing in the standard error logs.
In our database, we have application related data tables and transaction related data tables. since there is huge amount of records in my transaction table I want to ignore them while taking backup. So basically when I run a scheduler I want schema + data for application related tables and only schema for transaction related data tables.
I was suggested to use generate script. however I'm not sure if it would work because my application tables are linked with each other and my primary key columns are generally identity columns.
backup few tables with data+schema and other tables with only schema
For such a scenario, a regular SQL Server Backup functionality will not work at all, because there is no way to split data and structure and no way to avoid backup of some tables.
Even if you will perform a filegroup backup, it does not mean that you can restore only that filegroup and leave other tables as is. The filegroup backups just do not work this way.
Therefore, scripting can be one of the solutions:
Create a script of data and structure for smaller tables
Create a script of the structure only of transactional tables
Another approach is a dump necessary data and structure into a separate database with a further backup:
Something like:
SELECT * INTO ExportDB.dbo.Table1
SELECT * INTO ExportDB.dbo.Table2
SELECT * INTO ExportDB.dbo.Table3
--- two tables below will have no data, only a structure
SELECT * INTO ExportDB.dbo.Table4 WHERE 1=0 -- A large transactional table 1
SELECT * INTO ExportDB.dbo.Table5 WHERE 1=0 -- A large Transactional table 1
BACKUP DATABASE ExportDB TO DISK='..'
DROP DATABASE ExportDB
However, native backups (that are not an option for your scenario) can ensure data consistency, enforced by PK and FK, while custom options I mentioned after, cannot really guarantee it
References:
How can I take backup of particular tables in SQL Server 2008 using T-SQL Script
I currently have SQL Server Transactional replication running. Server A (Publisher & Distributor) to Server B (Subscriber). Everything is working great. I just need to know whether i can add a table to the subscriber only in that database? will it affect my replication? must the databases be the exact same in terms of schema etc?
I need to add a table that's not part of the publishers published articles on Server B(Subscriber).
I just need to know whether i can add a table to the subscriber only
in that database?
Yes, you can. It won't affect to the replication, but, for example, if you create table dbo.A on subscriber database first and later you'll create table with the same name and schema on publisher database you can lost data in table dbo.A on subscriber because by default new articles on the subscriber will be drop if exists within initialize process.
You can change this behavior in publication properties.
must the databases be the exact same in terms of schema etc?
No, it must not. In transaction replication you can replicate either whole tables or some columns of those tables.
I've just come across something disturbing, I was trying to implement transactional replication from a database whose design is not under our control . This replication was in order to perform reporting without taxing the system too much. Upon trying the replication only some of the tables went across.
On investigation tables were not selected to be replicated because they don't have a primary key, I thought this cannot be it is even shown as a primary key if I use ODBC and ms access but not in management studio. Also the queries are not ridiculously slow.
I tried inserting a duplicate record and it failed saying about a unique index(not a primary key). Seems to be the tables have been implemented using a unique index as oppose to a primary key. Why I do not know I could scream.
Is there anyway to perform transactional replication or an alternative, it needs to be live (last minute or two). The main db server is currently sql 2000 sp3a and the reporting server 2005.
The only thing I have currently thought of trying is setting the replication up as if it is another type of database. I believe replication to say oracle is possible would this force the use of say an ODBC driver like I assume access is using hence showing a primary key. I don't know if that is accurate out of my depth on this.
As MSDN states, it is not possible to create a transactional replication on tables without primary keys. You could use Merge replication (one way), that doesn't require a primary key, and it automatically creates a rowguid column if it doesn't exist:
Merge replication uses a globally
unique identifier (GUID) column to
identify each row during the merge
replication process. If a published
table does not have a uniqueidentifier
column with the ROWGUIDCOL property
and a unique index, replication adds
one. Ensure that any SELECT and INSERT
statements that reference published
tables use column lists. If a table is
no longer published and replication
added the column, the column is
removed; if the column already
existed, it is not removed.
Unfortunately, you will have a performance penalty if using merge replication.
If you need to use replication for reporting only, and you don't need the data to be exactly the same as on the publisher, then you could consider snapshot replication also