FIX: Update on a Table with INT and BIT Columns May Zero Out INT Columns

Article translations Article translations
Article ID: 294872 - View products that this article applies to.
This article was previously published under Q294872
BUG #: 352839 (SHILOH_BUGS)
Expand all | Collapse all

SYMPTOMS

A table that was created with int columns, which appear somewhere after a bit column, may have the int columns zeroed out when other columns in the table are updated.

RESOLUTION

To resolve this problem, obtain the latest service pack for 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

WORKAROUND

To work around this problem, either:
  • Put all of the bit columns at the end when you create a table.

    -or-

  • Change the data type for the bit columns to tinyint.

STATUS

Microsoft has confirmed that this is a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.

MORE INFORMATION


To reproduce the problem, use the code that follows.

Removing any of the columns or changing the data types of the BIT columns prevents the problem from occurring. In the following example the integer columns are set to zero even though they are not included in the SET clause of the update.
CREATE TABLE [dbo].[BitTest] (
 [KeyID] [int] NOT NULL ,
 [Promote] [bit] NULL ,
 [IntegerA2] [int] NULL ,
 [IntegerB2] [int] NULL ,
 [IntegerX2] [int] NULL ,
 [IntegerY2] [int] NULL ,
 [IntegerZ2] [int] NULL , 
 [P2State] [int] NULL ,
 [C1State] [int] NULL ,
 [P1EntityName] [varchar] (50)  NULL,
 [P1FirstName] [varchar] (25)  NULL,
 [P1MiddleInitial] [varchar] (1) NULL ,
 [P1LastName] [varchar] (35)  NULL ,
 [P1Address1] [varchar] (35)  NULL ,
 [P1Address2] [varchar] (35)  NULL ,
 [P1Address3] [varchar] (35)  NULL ,
 [P1City] [varchar] (30)  NULL ,
 [P1SSN] [varchar] (9)  NULL ,
 [P1Percent] [varchar] (3)  NULL ,
 [P1Cancel] [bit] NULL ,
 [P1Allowed] [bit] NULL ,
 [P2EntityName] [varchar] (50)  NULL,
 [P2FirstName] [varchar] (25)  NULL,
 [P2MiddleInitial] [varchar] (1) NULL ,
 [P2LastName] [varchar] (35)  NULL ,
 [P2Address1] [varchar] (35)  NULL ,
 [P2Address2] [varchar] (35)  NULL ,
 [P2Address3] [varchar] (35)  NULL ,
 [P2City] [varchar] (30)  NULL ,
 [P2ZIP] [varchar] (15)  NULL ,
 [P2SSN] [varchar] (9)  NULL ,
 [P2Percent] [varchar] (3)  NULL ,
 [P2Cancel] [bit] NULL ,
 [P2Allowed] [bit] NULL ,
 [C1EntityName] [varchar] (50)  NULL,
 [C1FirstName] [varchar] (25)  NULL,
 [C1MiddleInitial] [varchar] (1) NULL ,
 [C1Address1] [varchar] (35)  NULL ,
 [C1Address2] [varchar] (35)  NULL ,
 [C1Address3] [varchar] (35)  NULL ,
 [C1City] [varchar] (30)  NULL ,
 [C1Cancel] [bit] NULL ,
 [C1Allowed] [bit] NULL ,
 [C2EntityName] [varchar] (50)  NULL,
 [C2Address3] [varchar] (35)  NULL ,
 [C2Percent] [varchar] (3)  NULL ,
 [C2Cancel] [bit] NULL ,
 [C2Allowed] [bit] NULL ,
 [IntegerC2] [int] NULL, 
 [col1] bit NULL
) 
GO
insert BitTest (KeyID,IntegerA2,IntegerB2,IntegerZ2,IntegerC2) 
	values (101, 4, 4, 4, 4)
GO
Select  IntegerA2,IntegerB2,IntegerZ2,IntegerC2
From  BitTest
GO
Update  BitTest
set  
 C2Allowed = null,
 Promote = null,
 P1EntityName = null,
 P2EntityName = null,
 C1EntityName = null,
 C2EntityName = null,
 C1Address3 = null,
 P1Address3 = null,
 P2Address3 = null,
 C2Address3 = null,
 P1FirstName = 'FirstName',
 P1MiddleInitial = null,
 P1LastName = 'LastName',
 P1Address1 = null,
 P1Address2 = null,
 P1City = null,
 P1SSN = '555555555',
 P1Percent = null,
 P2FirstName = null,
 P2MiddleInitial = null,
 P2LastName = null,
 P2Address1 = null,
 P2Address2 = null,
 P2City = null,
 P2State = null,
 P2SSN = null,
 IntegerX2 = null,
 P2Percent = null,
 C1FirstName = null,
 C1MiddleInitial = null,
 C1Address1 = null,
 C1Address2 = null,
 C1City = null,
 C1State = null,
 P2ZIP = null
GO
Select  IntegerA2,IntegerB2,IntegerZ2,IntegerC2
From  BitTest
GO  
				

Properties

Article ID: 294872 - Last Review: November 5, 2003 - Revision: 3.2
APPLIES TO
  • Microsoft SQL Server 2000 Standard Edition
Keywords: 
kbbug kbfix kbsqlserv2000sp1fix KB294872

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com