Microsoft KB Archive/936534

From BetaArchive Wiki
Knowledge Base


Article ID: 936534

Article Last Modified on 8/20/2007



APPLIES TO

  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Enterprise X64 Edition
  • Microsoft SQL Server 2005 Enterprise Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Standard X64 Edition
  • Microsoft SQL Server 2005 Standard Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Workgroup Edition



Bug#: 50001158 (SQL Hotfix)

SYMPTOMS

Consider the following scenario. You configure a transactional replication in Microsoft SQL Server 2005. You create the initial snapshot successfully on the publisher. In this scenario, when the Distribution Agent tries to apply the snapshot to the subscriber, you receive the following error message:

Error: 137, Severity: 15, State: 2
Must declare the scalar variable "@Variable".

This issue occurs if the following conditions are true:

  • The transactional replication contains a created article that is based on a table that has computed columns.
  • The primary key column is sorted after the computed columns are sorted.
  • From the syscolumns system table, you can see that the column ID of the primary key column is larger than column IDs of the computed columns.
  • The publication uses concurrent snapshot processing.


CAUSE

The Distribution Agent creates a stored procedure to insert data on the subscriber. However, the stored procedure has incorrect parameter numbers.

RESOLUTION

Cumulative update information

To resolve this issue, obtain cumulative update package 2 for SQL Server 2005 Service Pack 2 (build 3175). For more information about how to obtain cumulative update package 2 for SQL Server 2005 Service Pack 2 (build 3175), click the following article number to view the article in the Microsoft Knowledge Base:

936305 Cumulative update package 2 for SQL Server 2005 Service Pack 2 is available


WORKAROUND

To work around this issue, use one of the following methods:

  • When you create the underlying table of the article, make sure that the primary key column is sorted before the computed columns are sorted.
  • Use native snapshot processing or database snapshot processing instead of concurrent snapshot processing.


STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

For example, this issue occurs when you use the following statement to create the underlying table of the article:

CREATE TABLE [dbo].[test](
    [col1] [char](10) NOT NULL,
    [col2] [char](10) NOT NULL,
    [col_1_2]  AS ([col1] + [col2]),
    [ID] [int] IDENTITY(1,1) NOT FOR REPLICATION PRIMARY KEY NOT NULL
)

Keywords: kbfix kbsql2005repl kbexpertiseadvanced kbpubtypekc kbqfe kbhotfixserver KB936534