Αναγν. άρθρου: 820675 - Τελευταία αναθεώρηση: Τετάρτη, 22 Δεκεμβρίου 2010 - Αναθεώρηση: 2.0

Τρόπος αμφίδρομης γραφής εφαρμογή αναπαραγωγής συναλλαγών

Συμβουλή συστήματοςΑυτό το άρθρο ισχύει για διαφορετικό λειτουργικό σύστημα από αυτό που χρησιμοποιείτε. Το περιεχόμενο του άρθρου που ενδέχεται να μην σας αφορά έχει απενεργοποιηθεί.

Σε αυτήν τη σελίδα

Ανάπτυξη όλων | Σύμπτυξη όλων

Περίληψη

Αυτό το άρθρο βήμα προς βήμα περιγράφει τον τρόπο υλοποίησης αμφίδρομες συναλλαγές αναπαραγωγής. Αυτό το άρθρο περιγράφει επίσης τα θέματα που εμπλέκονται στην υλοποίηση αμφίδρομες συναλλαγές αναπαραγωγής.

Bidirectional Transactional Replication

Bidirectional transactional replication, also known as two-way transactional replication, permits a server to be both a publisher and a subscriber to the same data. Because the servers that participate in the replication will replicate any changes to the other servers, any changes are not be propagated back to the originating server.

For example, if you have two servers (Server A and Server B), the servers are said to be in bidirectional transactional replication if both of the following conditions are true:
  • The changes that are made to Table T1 at Server A are replicated to Table T1 at Server B.
  • The changes that are made to Table T1 at Server B are replicated to Table T1 at Server A.
Therefore, if a change originates from Server A, the change is replicated to Server B, but Server B does not propagate the same change back to Server A. Replication uses a loopback detection mechanism that the distributor uses to determine whether to send the changes back to originating server.

Plan the Topology for Bidirectional Transactional Replication

For bidirectional transactional replication, one of the servers can act as central subscriber, and all the other servers subscribe to the central subscriber. Therefore, any changes that originate at a server are replicated to the central subscriber, and then the central subscriber, in turn, replicates the changes to all the other servers that participate in the replication. However, with the help of the loopback detection mechanism, the distributor stops the change from being propagated to the originating server.

For example, if three servers (Server A, Server B, and Server C) participate in bidirectional transactional replication and Server A is the central subscriber, the publishers and subscribers are maintained in the following ways:
  • Server A publishes to Server B and Server C.
  • Server A subscribes from Server B and Server C.
  • Server B publishes to and subscribes from only Server A.
  • Server C publishes to and subscribes from only Server A.
Therefore, any change that originates at Server B is replicated to Server A and Server C.

Conflicts in Bidirectional Transactional Replication

When you make changes on a server that is participating in replication, the changes are replicated to all other participating servers. During this replication, conflicts may occur and replication may fail. The following list describes the possible conflicts and the ways that you can avoid these conflicts:
  • If you insert a record that has a key into a table on one of the servers and another record that has the same key already exists on the other servers that participate in the replication, the replication does not propagate the changes to the other servers.

    Suggested ActionTo avoid this problem, make sure that you use different keys on each server that participates in the replication. To do so, allocate a predetermined range of keys to each server that participates in the replication. You can also use a composite key on each server.
  • When you update a record that has been deleted on another server, the UPDATE statement affects zero rows on the server where the record has been deleted, and the replication fails with an error.

    Suggested ActionTo avoid this problem, perform one of the following steps:
    • Κατάργηση του@@ROWCOUNTcheck after the actual UPDATE statement in the update custom stored procedure.

      -ή-
    • Χρήση του-Skiperrorsparameter for the distribution agent to skip this error. For more information about skipping errors in transactional replication, visit the following Microsoft Web site:
      http://msdn2.microsoft.com/en-us/library/aa178842(SQL.80).aspx (http://msdn2.microsoft.com/en-us/library/aa178842(SQL.80).aspx)
      -ή-
    • Look for a record before the UPDATE statement in the update stored procedure. If no record exists, bypass the UPDATE statement, and the record is deleted on all the subscribers.
  • When you update a column in a record that is updated at the same time on another server, the data may be different on the two servers.

    Suggested ActionTo avoid this problem, determine if the data is being updated at the same time on other servers, and then take any necessary action. To do so, modify the update custom stored procedure and use XCALL syntax to call the update stored procedure. The XCALL syntax provides the values for all the columns before the update procedure is called and provides the updated values in the column. You can compare the current value of the column against the value before the update stored procedure is called. If you see different values, the column is being updated at the same time by different servers. You can customize the stored procedure to select which value persists. For more information about how to use XCALL, visit the following Microsoft Web site:
    http://msdn2.microsoft.com/en-us/library/Aa237133(SQL.80).aspx (http://msdn2.microsoft.com/en-us/library/Aa237133(SQL.80).aspx)
    ΣΗΜΕΙΩΣΗYou can specify the XCALL syntax to call the corresponding update stored procedure or delete stored procedure by usingsp_addarticleduring publication. You can also specify the XCALL syntax by using SQL Server Enterprise Manager. Για να το κάνετε αυτό, ακολουθήστε τα εξής βήματα:
    1. In SQL Server Enterprise Manager, locate the publication that you want.
    2. Right-click the publication, and then clickΙδιότητες (Properties).
    3. Κάντε κλικ στην καρτέλαArticlestab, locate the article, and then click the article properties button (...) next to the article.
    4. ΣτοTable Article Propertiesπαράθυρο διαλόγου πλαίσιο, κάντε κλικ στοCommandsTAB.
    5. ΣτοReplace UPDATE commands with this stored procedure callπλαίσιο κειμένου, πληκτρολογήστεXCALL, και στη συνέχεια κάντε κλικ στο κουμπίOk.
    6. ΣτοPublication Propertiesπαράθυρο διαλόγου πλαίσιο, κάντε κλικ στο κουμπίOk.
  • When you update different columns in a record, simultaneous updates of different columns of a record may sometimes lead to conflicts.

    Suggested ActionTo avoid this problem, determine if the different columns in the same record are updated at the same time, and then take any necessary action. To do so, modify the update custom stored procedure, and then use the XCALL syntax to call the update stored procedure. Because the XCALL syntax provides the values before the update stored procedure is called, you can add one of the following options to the update stored procedure before the actual update is performed:
    • Compare the current values of all the columns against their values before the update stored procedure is called.
    • Add a column to represent the row version and to compare its current value with its value before the update stored procedure is called.
    Different values indicate that different columns are being updated at the same time. You can then decide whether to update the column.
  • When you delete a row that is being updated by another server at the same time, the replication may fail.

    Suggested ActionTo determine if a row is updated and deleted at the same time, use the XCALL syntax in the delete stored procedure. Compare every column of the row that is being deleted against the values before the delete stored procedure is called. Different values indicate that these updates are being performed at the same time. You can either delete or retain the updated row.

    ΣΗΜΕΙΩΣΗEven if you do not delete the record on the subscriber, the record no longer exists on the server that originated the DELETE statement.
  • When you delete a row that is being deleted at the same time on another server that is participating in the replication, the replication fails because the DELETE statement does not affect any rows on some of the subscribers.

    Suggested ActionTo avoid this problem, perform one of the following steps:
    • Κατάργηση του@@ROWCOUNTcheck after the actual DELETE statement in the update custom stored procedure.

      -ή-
    • Χρήση του-Skiperrorsη παράμετρος με τον αντιπρόσωπο της διανομής για να παραβλέψετε αυτό το σφάλμα. Για περισσότερες πληροφορίες σχετικά με τα σφάλματα skipping στην αναπαραγωγή συναλλαγών, επισκεφθείτε την ακόλουθη τοποθεσία της Microsoft στο Web:
      .aspx http://msdn2.Microsoft.com/en-us/library/aa178842 (SQL.80) (http://msdn2.microsoft.com/en-us/library/aa178842(SQL.80).aspx)
ΣΗΜΕΙΩΣΗΚάθε ανάπτυξης μπορεί να απαιτεί μια διαφορετική προσέγγιση για να επιλύσετε αυτές τις διενέξεις, ανάλογα με τις απαιτήσεις της εργασίας. Αυτές οι διενέξεις είναι ευκολότερο για την επίλυση όταν εμπλέκονται μόνο δύο διακομιστές. Όταν εμπλέκονται περισσότερα από δύο διακομιστές, ενδέχεται να μπορείτε να χρησιμοποιήσετε αποθηκευμένες διαδικασίες για να προσδιορίσετε το διακομιστή που προέρχονται οι αλλαγές. Ενημερωμένη έκδοση που είναι αποθηκευμένη διαδικασία που χρησιμοποιείται για να ενημερώσετε τις εγγραφές στο διακομιστή C δεν γνωρίζει αν η αλλαγή δημιουργήθηκε στο διακομιστή A ή το διακομιστή β. Αναπαραγωγής συγχώνευσης, σε αντίθεση με τις συναλλαγές αναπαραγωγής δεν έχει σχεδιαστεί για την επίλυση των διενέξεων. Ανάπτυξη συναλλαγών αναπαραγωγή μόνο σε σενάρια όπου αποφεύγονται διενέξεις αντί να επιλυθεί.

Υλοποίηση αμφίδρομης γραφής συναλλαγών αναπαραγωγής

Για να υλοποιήσετε τις αμφίδρομες συναλλαγές αναπαραγωγής, πρέπει να ισχύει όλες οι ακόλουθες συνθήκες:
  • Τα δεδομένα είναι συγχρονισμένα μεταξύ των διακομιστών αναπαραγωγής.
  • Βρίσκονται αποθηκευμένες διαδικασίες που χρησιμοποιούνται από αναπαραγωγή σε όλες τις βάσεις δεδομένων που συμμετέχουν.
  • Η συνδρομή έχει οριστεί με τη χρήση του@ loopback_detection = 'true'Παράμετρος.

    ΣΗΜΕΙΩΣΗΗ επιλογήΟρισμός @ loopback_detection = 'true'Δεν είναι διαθέσιμη αυτήν τη στιγμή στο περιβάλλον εργασίας χρήστη. Επομένως, πρέπει να εγγραφείτε, χρησιμοποιώντας τοsp_addsubscriptionαποθηκευμένη διαδικασία.
Εάν εκτελείτε τη δημιουργία αντιγράφων ασφαλείας και επαναφοράς, να θυμάστε ότι διαφορετικές τοποθεσίες απαιτούν διαφορετικούς περιορισμούς πρωτεύοντος κλειδιού, για να βεβαιωθείτε ότι δεν δημιουργούνται διπλές πρωτεύοντα κλειδιά. Θυμηθείτε επίσης να δημιουργήσετε όλους τους περιορισμούς με τον όρο NOT FOR ΑΝΑΠΑΡΑΓΩΓΗΣ.

Μπορείτε να χρησιμοποιήσετε το παράδειγμα που ακολουθεί, για να ρυθμίσετε τις αμφίδρομες συναλλαγές αναπαραγωγής σε έναν υπολογιστή που εκτελεί τον SQL Server 2000.

ΣΗΜΕΙΩΣΗΟι προτάσεις Transact-SQL παρατίθενται για κάθε ένα από τα παρακάτω βήματα. Εκτελέστε τις προτάσεις Transact-SQL για την εκτέλεση της εργασίας που αναφέρεται στο προηγούμενο βήμα.
  1. Δημιουργία ενός διανομέα, οι εκδότες και συνδρομητές σε έναν υπολογιστή που εκτελεί τον SQL Server. Για να το κάνετε αυτό, ακολουθήστε τα εξής βήματα:
    1. Δημιουργήστε δύο βάσεις δεδομένων:
      use master
      go
      
      create database test1
      go
      
      create database test2
      go
      
    2. Δημιουργήστε τους δύο πίνακες που έχουν έναΤαυτότητα (Identity)ο ορισμός στήλης με την επιλογή NOT FOR ΑΝΑΠΑΡΑΓΩΓΗΣ:
      use test1
      go
      
      create table two_way_test1 
      (
      	pkcol		INTEGER PRIMARY KEY NOT NULL,
      	intcol		INTEGER IDENTITY(1,1) NOT FOR REPLICATION,
       	charcol		CHAR(100),
      	timestampcol 	TIMESTAMP
      )
      
      use test2
      go
      
      create table two_way_test2 
      (
      	pkcol 		INTEGER PRIMARY KEY NOT NULL,
      	intcol 		INTEGER IDENTITY(1000000000,1) NOT FOR REPLICATION,
       	charcol 	CHAR(100),
       	timestampcol 	TIMESTAMP
      )
      go
    3. Εκχωρήστε ένα προκαθορισμένο εύρος τιμών στη στήλη πρωτεύοντος κλειδιού, έτσι ώστε οι τιμές σε διαφορετικούς διακομιστές δεν βρίσκονται στην ίδια περιοχή. Για παράδειγμα, μπορείτε να επιβάλετε 1-1000, με την περιοχή κλειδιού για τοtwo_way_test1πίνακας με τοTest1βάση δεδομένων και στη συνέχεια επιβολή 1001-2000 με την περιοχή κλειδιού γιαtwo_way_test2πίνακας με τοTest2Database. Για να γίνει αυτό, χρησιμοποιήστε τον ακόλουθο κώδικα:
      	-- Constraint to enforce a range of values between 1 and 1000 in database test1 
      use test1
      go
      
      alter table 
      	two_way_test1 
      with nocheck 
      add constraint 
      	checkprimcol check NOT FOR REPLICATION 
      	(
      		pkcol BETWEEN 1 and 1000
      	) 
      go 
      
      
      use test2
      go
      
      	-- Constraint to enforce a range of values between 1001 and 2000 in the database test2 
      
      alter table 
      	two_way_test2
      with nocheck 
      add constraint 
      	checkprimcol check NOT FOR REPLICATION 
      	(
      		pkcol BETWEEN 1001 and 2000
      	) 
      go 
      
      
  2. Ενεργοποίηση του διακομιστή με το διανομέα και στη συνέχεια να δημιουργήσετε μια βάση δεδομένων της διανομής:
    use master
    go
    sp_adddistributor @distributor = '<distributor name>' 
    go
    use master
    go
    sp_adddistributiondb @database='distribution'
    go
  3. Ενεργοποίηση όλων των υπολογιστών εκτελεί τον SQL Server που συμμετέχουν στην αναπαραγωγή του ως εκδότες:
    use master
    go
    
    exec sp_adddistpublisher 
    	@publisher = '<Your Server Name>', 
    	@distribution_db ='distribution', 
    	@security_mode = 0, 
    	@login = 'sa', 
    	@password = 'sa',
    	@working_directory ='<Location of Directory>'
  4. Ενεργοποίηση όλων των εντοπισμένων βάσεων δεδομένων για την αναπαραγωγή:
    use master
    go
    
    exec sp_replicationdboption N'test1', N'publish', true
    go
    
    exec sp_replicationdboption N'test2', N'publish', true
    go
    
  5. Δημιουργία προσαρμοσμένης αποθηκευμένες διαδικασίες για INSERT, UPDATE, και DELETE λειτουργίες σε όλες τις βάσεις δεδομένων για να εφαρμόσετε τις αλλαγές που έγιναν κατά τη διάρκεια της αναπαραγωγής.

    ΣΗΜΕΙΩΣΗΣυνήθως, όταν εισαγάγετε μια τιμή σε μια στήλη ΙDENTITY, την επιλογή IDENTITY_INSERT για τον πίνακα πρέπει να είναι ON. Αυτή η εργασία επιτυγχάνεται με την επιλογή NOT FOR ΑΝΑΠΑΡΑΓΩΓΗΣ για εισερχόμενη αναπαραγωγή παράγοντες.

    Δεν μπορείτε να ενημερώσετε τις τιμές στη στήλη IDENTITY. Επομένως, όταν ενημερώνετε τις τιμές κατά τη διάρκεια της αναπαραγωγής, πρέπει να καταργήσετε τις παλιές τιμές και να εισαγάγετε τις νέες τιμές. Για να δημιουργήσετε το προσαρμοσμένο αποθηκευμένες διαδικασίες, ακολουθήστε τα εξής βήματα:
    1. Δημιουργία προσαρμοσμένης αποθηκευμένων διαδικασιών σε τοTest1Database:
      use test1
      go
      
      -- INSERT Stored Procedure
      
      create procedure sp_ins_two_way_test1	
      	@pkcol int, 
      	@intcol int, 
      	@charcol char(100), 
      	@timestampcol timestamp,
      	@rowidcol uniqueidentifier
      as
      	insert into two_way_test1 
      	(
      		pkcol,
      		intcol,
      		charcol
      	) 
      	values
      	(
      		@pkcol, 
      		@intcol, 
      		@charcol
      	)
      go
      
      --UPDATE Stored Procedure
      
      create procedure sp_upd_two_way_test1	
      	@pkcol int, 
          	@intcol int, 
          	@charcol char(100), 
          	@timestampcol timestamp,
      	@rowidcol uniqueidentifier,
          	@old_pkcol int
      as
      	declare @x int
      	declare @y int
      	declare @z char(100)
       
      	select 
      		@x=pkcol, 
      		@y=intcol, 
      		@z=charcol 
      	from 
      		two_way_test1 
      	where 
      		pkcol = @pkcol
      
      
      
      	delete 
      		two_way_test1 
      	where 
      		pkcol=@pkcol
      
      
      
      	insert into two_way_test1 
      	(
      		pkcol, 
      		intcol, 
      		charcol
      	) 
      	values
      	(
      		case isnull(@pkcol,0) when 0 then @x else @pkcol end,
      		case isnull(@intcol,0) when 0 then @y else @intcol end,
      		case isnull(@charcol,'N') when 'N' then @z else @charcol end
      	)
      go
      
      --  DELETE Stored Procedure
      
      create procedure sp_del_two_way_test1 
      	@old_pkcol int
      as
      	delete 
      		two_way_test1 
      	where 
      		pkcol = @old_pkcol
      go
      
      
    2. Δημιουργία προσαρμοσμένης αποθηκευμένων διαδικασιών σε τοTest2Database:
      use test2
      go
      
      -- INSERT Stored Procedure
      
      create procedure sp_ins_two_way_test2	
      	@pkcol int, 
      	@intcol int, 
      	@charcol char(100), 
      	@timestampcol timestamp,
      	@rowidcol uniqueidentifier
      as
      	insert into two_way_test2 
      	(
      		pkcol,
      		intcol,
      		charcol
      	) 
      	values
      	(
      		@pkcol, 
      		@intcol, 
      		@charcol
      	)
      go
      
      --UPDATE Stored Procedure
      
      create procedure sp_upd_two_way_test2	
      	@pkcol int, 
          	@intcol int, 
          	@charcol char(100), 
          	@timestampcol timestamp,
      	@rowidcol uniqueidentifier,
          	@old_pkcol int
      as
      	declare @x int
      	declare @y int
      	declare @z char(100)
       
      	select 
      		@x=pkcol, 
      		@y=intcol, 
      		@z=charcol 
      	from 
      		two_way_test2 
      	where 
      		pkcol = @pkcol
      
      
      
      	delete 
      		two_way_test2 
      	where 
      		pkcol=@pkcol
      
      
      
      	insert into two_way_test2 
      	(
      		pkcol, 
      		intcol, 
      		charcol
      	) 
      	values
      	(
      		case isnull(@pkcol,0) when 0 then @x else @pkcol end,
      		case isnull(@intcol,0) when 0 then @y else @intcol end,
      		case isnull(@charcol,'N') when 'N' then @z else @charcol end
      	)
      go
      
      
      --  DELETE Stored Procedure
      
      create procedure sp_del_two_way_test2 
      	@old_pkcol int
      as
      	delete 
      		two_way_test2 
      	where 
      		pkcol = @old_pkcol
      go
      
  6. Δημιουργήστε μια δημοσίευση συναλλαγών και προσθέστε στη δημοσίευση και στις δύο άρθρα τουTest1και τοTest2βάσεις δεδομένων:
    --In the database test1.
    
    use test1
    go
    
    --  Adding the transactional publication.
    exec sp_addpublication 
    	@publication = N'two_way_pub_test1', 
    	@restricted = N'false',
    	@sync_method = N'native', 
    	@repl_freq = N'continuous',
    	@description = N'Transactional publication of database test1.',
    	@status = N'active', 
    	@allow_push = N'true', 
    	@allow_pull = N'true',
    	@allow_anonymous = N'false', 
    	@enabled_for_internet = N'false',
    	@independent_agent = N'false', 
    	@immediate_sync = N'false',
    	@allow_sync_tran = N'true', 
    	@autogen_sync_procs = N'true',
    	@retention = 72
    go
    
    exec sp_addpublication_snapshot 
    	@publication = N'two_way_pub_test1',
    	@frequency_type = 4,
    	@frequency_interval = 1, 
    	@frequency_relative_interval = 0,
    	@frequency_recurrence_factor = 1, 
    	@frequency_subday = 1,
    	@frequency_subday_interval = 0, 
    	@active_start_date = 0,
    	@active_end_date = 0, 
    	@active_start_time_of_day = 233000,
    	@active_end_time_of_day = 0
    go
    
    --  Adding the transactional articles.
    
    exec sp_addarticle 
    	@publication = N'two_way_pub_test1', 
    	@article = N'two_way_test1',
    	@source_owner = N'dbo', 
    	@source_object = N'two_way_test1',
    	@destination_table = N'two_way_test1', 
    	@type = N'logbased',
    	@creation_script = null, 
    	@description = null, 
    	@pre_creation_cmd = N'drop',
            @schema_option = 0x00000000000000F1, 
    	@status = 16,
    	@vertical_partition = N'false', 
    	@ins_cmd = N'CALL sp_ins_two_way_test2',
    	@del_cmd = N'CALL sp_del_two_way_test2',
    	@upd_cmd = N'CALL sp_upd_two_way_test2', 
    	@filter = null,
    	@sync_object = null
    go
    
    --  In the database test2
    use test2
    go
    
    --  Adding the transactional publication.
    
    exec sp_addpublication 
    	@publication = N'two_way_pub_test2', 
    	@restricted = N'false',
    	@sync_method = N'native', 
    	@repl_freq = N'continuous',
    	@description = N'Transactional publication of database test2',
    	@status = N'active', 
    	@allow_push = N'true', 
    	@allow_pull = N'true',
    	@allow_anonymous = N'false', 
    	@enabled_for_internet = N'false',
    	@independent_agent = N'false', 
    	@immediate_sync = N'false',
    	@allow_sync_tran = N'true', 
    	@autogen_sync_procs = N'true',
    	@retention = 72
    go
    
    exec sp_addpublication_snapshot 
    	@publication = N'two_way_pub_test2',
    	@frequency_type = 4,
    	@frequency_interval = 1, 
    	@frequency_relative_interval = 0,
    	@frequency_recurrence_factor = 1, 
    	@frequency_subday = 1,
    	@frequency_subday_interval = 0, 
    	@active_start_date = 0,
    	@active_end_date = 0, 
    	@active_start_time_of_day = 233000,
    	@active_end_time_of_day = 0
    go
    
    --  Adding the transactional articles.
    exec sp_addarticle 
    	@publication = N'two_way_pub_test2', 
    	@article = N'two_way_test2',
    	@source_owner = N'dbo', 
    	@source_object = N'two_way_test2',
    	@destination_table = N'two_way_test2', 
    	@type = N'logbased',
    	@creation_script = null, 
    	@description = null, 
    	@pre_creation_cmd = N'drop',
    	@schema_option = 0x00000000000000F1, 
    	@status = 16,
    	@vertical_partition = N'false', 
    	@ins_cmd = N'CALL sp_ins_two_way_test1',
    	@del_cmd = N'CALL sp_del_two_way_test1',
    	@upd_cmd = N'CALL sp_upd_two_way_test1', 
    	@filter = null,
    	@sync_object = null
    go
    
  7. Ενεργοποίηση ως συνδρομητές όλους τους διακομιστές που συμμετέχουν στην αναπαραγωγή:
    exec sp_addsubscriber 
    	@subscriber = '<Your Server Name>', 
    	@login = '<login name>', 
    	@password = '<password>'
    go
    
    
  8. Προσδιορισμός μία από τις βάσεις δεδομένων ως κεντρική συνδρομητή. Create transactional subscriptions in all the databases that participate in the replication so that all the databases subscribe to the central subscriber and the central subscriber subscribes to all the other databases.

    For example, in this scenario, theTest1database is the central subscriber. Create transactional subscriptions in thetest2database that subscribe to the publication atTest1and in theTest1database that subscribe to the publication attest2.

    ΣΗΜΕΙΩΣΗCreate all the subscriptions with the LOOPBACK_DETECTION option enabled.

    To do so, use the following code:
    --Adding the transactional subscription in test1.
    
    use test1
    go
    exec sp_addsubscription 
    	@publication = N'two_way_pub_test1', 
    	@article = N'all', 
    	@subscriber = '<Your Server Name>', 
    	@destination_db = N'test2', 
    	@sync_type = N'none', 
    	@status = N'active', 
    	@update_mode = N'sync tran', 
    	@loopback_detection = 'true'
    go
    
    -- Adding the transactional subscription in test2.
    
    use test2
    go
    exec sp_addsubscription 
    	@publication = N'two_way_pub_test2', 
    	@article = N'all', 
    	@subscriber = '<Your Server Name>', 
    	@destination_db = N'test1', 
    	@sync_type = N'none', 
    	@status = N'active', 
    	@update_mode = N'sync tran', 
    	@loopback_detection = 'true'
    go
    
ΣΗΜΕΙΩΣΗYou can also create custom stored procedures for all publications by using thesp_scriptpublicationcustomprocsσύστημα αποθηκευμένης διαδικασίας. Για περισσότερες πληροφορίες σχετικά με τοsp_scriptpublicationcustomprocssystem stored procedure, see the "sp_scriptpublicationcustomprocs" topic in SQL Server 2000 Updated Books Online.

ΣΗΜΕΙΩΣΗSQL Query Analyzer returns only 256 characters per column. You can change this option to the maximum allowed value.



Αναφορές

Για περισσότερες πληροφορίες, κάντε κλικ στους αριθμούς των άρθρων παρακάτω για να προβάλετε τα άρθρα της Γνωσιακής Βάσης της Microsoft (Knowledge Base):
320499  (http://support.microsoft.com/kb/320499/EN-US/ ) How To Manually Synchronize Replication Subscriptions by Using Backup or Restore
299903  (http://support.microsoft.com/kb/299903/ ) FIX: sp_scriptpublicationcustomprocs Generates Replication Stored Procedures
327817  (http://support.microsoft.com/kb/327817/ ) INF: Use the "-SkipErrors" Parameter in Distribution Agent Cautiously
For additional information about implementing bidirectional transactional replication in SQL Server 7.0, click the following article numbers to view the articles in the Microsoft Knowledge Base:
300164  (http://support.microsoft.com/kb/300164/EN-US/ ) INF: How to Set Up an Identity Column on both the Publisher and the Subscriber with Transactional Replication
240235  (http://support.microsoft.com/kb/240235/ ) BUG: "Implementing Nonpartitioned, Bi-directional, Transactional Replication" Sample in Books Online Contains Errors

Οι πληροφορίες σε αυτό το άρθρο ισχύουν για:
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 2000 64-bit Edition
Λέξεις-κλειδιά: 
kbreplication kbcode kbtsql kbhowtomaster kbmt KB820675 KbMtel
Μηχανικά μεταφρασμένοΜηχανικά μεταφρασμένο
ΣΗΜΑΝΤΙΚΟ: Αυτό το άρθρο είναι προϊόν λογισμικού μηχανικής μετάφρασης της Microsoft και όχι ανθρώπινης μετάφρασης. Η Microsoft σάς προσφέρει άρθρα που είναι προϊόντα ανθρώπινης αλλά και μηχανικής μετάφρασης έτσι ώστε να έχετε πρόσβαση σε όλα τα άρθρα της Γνωσιακής Βάσης μας στη δική σας γλώσσα. Ωστόσο, ένα άρθρο που έχει προκύψει από μηχανική μετάφραση δεν είναι πάντα άριστης ποιότητας. Ενδέχεται να περιέχει λεξιλογικά, συντακτικά ή γραμματικά λάθη, όπως ακριβώς τα λάθη που θα έκανε ένας μη φυσικός ομιλητής επιχειρώντας να μιλήσει τη γλώσσα σας. Η Microsoft δεν φέρει καμία ευθύνη για τυχόν ανακρίβειες, σφάλματα ή ζημίες που προκύψουν λόγω τυχόν παρερμηνειών στη μετάφραση του περιεχομένου ή χρήσης του από τους πελάτες της. Επίσης, η Microsoft πραγματοποιεί συχνά ενημερώσεις στο λογισμικό μηχανικής μετάφρασης.
Η αγγλική έκδοση αυτού του άρθρου είναι η ακόλουθη:820675  (http://support.microsoft.com/kb/820675/en-us/ )