FIX: Procedure for Repl. Can Fail When Referencing NCI

Last reviewed: May 1, 1997
Article ID: Q138290

The information in this article applies to:
  • Microsoft SQL Server, version 6.0
BUG# NT: 10981 (6.00)

SYMPTOMS

If a published article has a stored procedure created FOR REPLICATION that references a column in a non-clustered index on the article's base table, the filter procedure can prevent a transaction from being replicated. Examining the MSjob_commands table in the distribution database can help you detect this problem.

CAUSE

The SELECT statement in the replication filter procedure is being incorrectly evaluated by SQL Server when applying the filter procedure against the logged change in the published database.

The most common occurrence of this problem is when a "restriction clause" for the article is created using SQL Enterprise Manager where the column listed in the clause is part of a non-clustered index.

This problem can also occur if you develop your own filter procedure using the CREATE PROCEDURE FOR REPLICATION command. This problem does not affect the proper synchronization of data when first subscribing, only changes made after synchronization.

WORKAROUND

  1. Drop the non-clustered index.

  2. Remove the column referenced in the filter procedure from the non- clustered index.

  3. Filter the replicated changes on the subscriber by using custom stored procedures.

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.0. This problem was corrected in Service Pack 2 for SQL Server version 6.0. For more information, contact your primary support provider.

MORE INFORMATION

If a "restriction clause" is specified when creating an article using SQL Enterprise Manager, a "filter stored procedure," which can be manually created using the CREATE PROCEDURE FOR REPLICATION command, is generated to include the criteria for the horizontal partition. Procedures of this type are applied by SQL Server as part of processing initiated by the Log Reader task.

For example, for the employee table in the pubs database, an article with a restriction clause of "lname like 'A%'" will result in the creation of the following replication filter procedure automatically by SQL Enterprise Manager:

CREATE PROCEDURE FLTR_employee_Table_1__10 FOR REPLICATION AS IF EXISTS (SELECT * FROM DBO.EMPLOYEE (NOLOCK) WHERE LNAME LIKE 'A%')

   RETURN 1
ELSE
   RETURN 0
END

In the above example, any modification affecting the employee table where lname LIKE 'A%' should be replicated to subscribers. However, if a non-clustered index was created on the lname column, these changes would not pass the filter stored procedure test and not be stored in the distribution database.


Additional query words: sql6 windows nt rep
Keywords : kbbug6.00 kbfix6.00.sp2 kbprg SSrvProg SSrvRep
Version : 6.0
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 1, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.