Microsoft KB Archive/280747

From BetaArchive Wiki

Article ID: 280747

Article Last Modified on 10/28/2003



APPLIES TO

  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft SQL Server 2000 Standard Edition



This article was previously published under Q280747

BUG #: 58158 (SQLBUG_70)
BUG #: 234633 (SQLBUG_2000)

SYMPTOMS

When you attempt to update a clustered index key, you may receive the following error message even though no constraints are violated:

Server: Msg 547, Level 16, State 1, Line 1
UPDATE statement conflicted with TABLE CHECK constraint 'CK_tblA'. The
conflict occurred in database 'pubs', table 'tblA'.
The statement has been terminated.

The above error occurs if all of the following conditions are true:

  • The table in question contains a composite clustered index.
  • Updates are made to one of the clustered index keys.
  • The table contains a unique nonclustered index on one of the clustered index keys.
  • The table has a CHECK constraint that checks for null values on any of the clustered index keys.


RESOLUTION

SQL Server 2000

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack


SQL Server 7.0

To resolve this problem, obtain the latest service pack for SQL Server 7.0. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

301511 INF: How to Obtain the Latest SQL Server 7.0 Service Pack


WORKAROUND

To avoid this problem, change the composite clustered index to a nonclustered index.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

SQL Server 2000

This problem was first corrected in SQL Server 2000 Service Pack 1.

SQL Server 7.0

This problem was first corrected in SQL Server 7.0 Service Pack 3.

MORE INFORMATION

To reproduce the problem, run the following code:

USE PUBS
GO
CREATE TABLE [tblA] (
    [col0] [int] IDENTITY (1, 1) not NULL ,
    [col1] [varchar] (10)   NULL,
    [col2] [varchar] (10)  NULL,
    [col3] [smallint] NULL ,
    
    CONSTRAINT [CK_tblA]
    CHECK ((([col1] is null) and ([col2] is null))
        or (([col1] is not null) and ([col2] is not null)))

)
GO

CREATE  CLUSTERED  INDEX [IXCL_tblA] 
ON [dbo].[tblA]
([col0], [col1]) 

GO

create unique nonclustered  index [IXNCL_tblA] 
ON [dbo].[tblA]([col0])
go

insert into tblA ([col1], [col2], [col3])
values ('AAA', 'BBB', 1)

update tblA
set col1='DDD'
                


Additional query words: violation

Keywords: kbbug kbfix kbsqlserv2000sp1fix KB280747