432 Chapter9•ManagingReplication Conflict Resolution In Merge Replication, you can set Publisher to win when a conflict exists. Ü Also, you have the option of setting the priorities for subscribers. Apart from default settings, you can customize the conflict resolution for Ü date, time, and values. In Peer-to-Peer Replication, conflict resolution is introduced with SQL Ü Server 2008, and the highest number of peer originator id wins when there is a conflict. DDL Replication DDL Replication is enabled by default. Ü DDL Replication will be failed at SQL Server 2000 when it is a subscriber Ü for Merge Replication. Security Considerations Recommended practice is to use a unique domain user account to connect Ü to publishers and distributors rather than using a SQL Server Agent account. A better option is to run the agent service account using the domain user Ü account. Replication Performance Always try to limit replication objects as much as possible. You can ignore Ü the unnecessary database objects and columns. Pull subscriber will reduce the load of the distributor when there are lots Ü of subscribers. Try to schedule creating snapshots during an off-peak time of the database Ü load. Monitoring Replication Monitor is a SQL Server in-built monitoring tool. Ü Performance Monitor (perfmon) also is used for replication monitoring. Ü You can create alerts so that operators can take proactive decisions. Ü Managing Replication • Chapter 9 433 Exam Objectives Frequently Asked Questions Q: What is the difference between replication and clustering? A: Clustering is for entire database server, and you can implement replication for database objects level and filter horizontally (rows) and vertically (columns). In clustering cost is higher than the replication. Q: What is the difference between replication and mirroring or log shipping? A: Mirroring or log shipping is for the entire database. You can implement replication for database objects level and filter horizontally (rows) and vertically (columns). In mirroring or log shipping, you will not have the option of accessing the database while data is in synchronizing mode, which is a possibility in replication. Q: Do I need a separate database server for distribution? A: No you can configure Distributor in the publication server. However, for the performance benefits, it is recommended to have a separate database server. Q: When there is a failure of one database that has connection to the replicated subscriber, is it possible to configure connection string so that it will be pointed to the other subscriber? A: No, You need to transfer it manually. Q: For transactional replication, do you need your database to be in full or bulk-logged recovery method? A: No. Recovery method can be anything in your database to support transaction replication. Q: How do you stop the trigger from being triggered when data is inserted from replication? A: You can write a trigger with the NOT FOR REPLICATION option so that the trigger will not execute for replicated data. CREATE TRIGGER trg_I_Code ON tblCODE AFTER INSERT 434 Chapter9•ManagingReplication NOT FOR REPLICATION AS <Trigger Code> Q: Is it possible to have two Insert/Update/Delete triggers on a table—FOR REPLICATION and NOT FOR REPLICATION? A: Yes. You can have more than one trigger with FOR REPLICATION and NOT FOR REPLICATION settings. Q: Is it possible to replicate a SQL Server 2008 database with a SQL Server 7 database? A: No. The database should be at least SQL Server 2000 to enable Merge Replication. Q: If you configure replication with a continuous scheduling option, will data be at the subscriber immediately? A: No. Though data should be replicated at Subscriber immediately, there can be latency that is governed by your network capabilities. Q: Is it possible to configure replication with both Publisher and Subscriber in the same server? A: Yes. Unlike mirroring or log shipping there are no such restrictions. Q: Do I need to take backups of a distribution database? A: Yes. The distribution database can be restored to the last backup without recon- figuring replication or reinitializing subscriptions. Usually, the Log Reader Agent connects to the publication database, scans the log, retrieves the next set of N transactions that need to be replicated, propagates them to the distribution database, and then indicates to the publication database that the transactions have been successfully committed at the distribution database. At this point, the publication database can truncate the part of the log that contains these transactions (provided they have been backed up). If the distribution database fails at this point and is restored to a previous backup, it will not be possible for the Log Reader Agent to deliver the missing transactions because the part of the log containing them may have been truncated. ManagingReplication•Chapter9 435 Q: What are the steps you need to enable logging in Merge Replication when there is an error? A: You should follow five steps: 1. Right-click on your merge agent for this publication. Select Agent Properties. 2. Select job steps and then select the Run Step option. Click Edit.36 3. At the end of your string type the following command: -OutputVerboseLevel 3 -Output C:\temp\repllog.txt 4. Click OK, and restart your merge agent. 5. If you get any errors, check the log for details in repllog.out. Q: How can I configure automatic redirect for my connection string when there is a failure in the replication? A: There is no automatic configuration for redirection in replication. You need to write your own code inside your application. Q: Is it possible to replicate different SQL Server versions in a replication topology? A: For all types of replication, the Distributor version must be no earlier than the Publisher version. For Transactional Replication, a Subscriber to a transactional publication can be any version within two versions of the Publisher version. For example, a SQL Server 2000 Publisher can have SQL Server 2008 Subscribers, and a SQL Server 2008 Publisher can have SQL Server 2000 Subscribers. For merge replication, a Subscriber to a merge publication can be any version no later than the Publisher version. 436 Chapter9•ManagingReplication SelfTest 1. You have a database and it was decided to implement load balancing technology so that it will reduce the current load in the existing database. However, after analyzing the existing database, it was found that you cannot have some columns like Salary or Credit card numbers in the secondary server. What technology are you going to use? A. Clustering B. Log Shipping C. Mirroring D. Replication 2. You are a DBA of an organization whose prime business is selling goods. The organization has several branches around the country. Prices of the goods are controlled by the central location and it needs to be propagated to all branches. Price change occurs once every two years. What replication type are you going to implement? A. Snapshot B. Transactional C. Peer-to-Peer D. Merge 3. You are a DBA of an organization whose main business is selling goods around the area. You have sales representatives who have PDAs with them. Before they travel to their clients, they need to download data from the server and at the end of the sales, they need to connect to the network and synchronize their data with the system. What replication type are you going to implement? A. Snapshot B. Transactional C. Peer-to-Peer D. Merge 4. You are a database architect in a data warehouse and you have a source system that is running in SQL Server 2005. You are referring to this database instance to generate Customer Slowly Changing Dimensions (SCD). The customer . within two versions of the Publisher version. For example, a SQL Server 2000 Publisher can have SQL Server 2008 Subscribers, and a SQL Server 2008 Publisher can have SQL Server 2000 Subscribers around the area. You have sales representatives who have PDAs with them. Before they travel to their clients, they need to download data from the server and at the end of the sales, they need. REPLICATION settings. Q: Is it possible to replicate a SQL Server 2008 database with a SQL Server 7 database? A: No. The database should be at least SQL Server 2000 to enable Merge Replication. Q: If