System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
321541
(http://support.microsoft.com/kb/321541/
)
FIX: SQL Server Might Return
Incorrect Results When You Use an Outer Join and a View
on a computer that is running Microsoft SQL Server
2000 Service Pack 2 (SP2).
The security hotfix described in
Microsoft
Security Bulletin MS02-061
(http://www.microsoft.com/technet/security/bulletin/MS02-061.mspx)
for Microsoft SQL Server 2000
SP2.
Microsoft SQL Server 2000 Service Pack 3 (SP3).
you might receive the following error message:
Insufficient
key column information for updating or refreshing.
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
(http://support.microsoft.com/kb/290211/
)
How to obtain the latest SQL Server 2000 service pack
The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.This problem was first corrected in Microsoft SQL Server 2000 Service Pack 4.
The hotfix discussed in this article regresses the fix that
is discussed in the following Microsoft Knowledge Base article:
321541
(http://support.microsoft.com/kb/321541/
)
FIX: SQL Server Might Return Incorrect Results When You Use an Outer Join and a View
Note To make the hotfix discussed in this article operational, you
must enable trace flag -T220, and restart SQL Server.
To enable the
trace flag, follow these steps:
Open SQL Enterprise Manager on the server.
Click to select the server that is experiencing the
problem.
Right-click the server, and then click
Properties.
On the General tab, click Startup
Parameters.
In the Startup Parameters dialog box, type
-T220, and then click Add.
Click OK.
Stop, and then restart the Mssqlserver service to restart
SQL Server.
An example of the problem and what the trace flag -T220
does follows. The example uses two sample tables named Test_Table1 and Test_Table2. Consider the following tables and view:
CREATE TABLE TEST_TABLE1 (
[CODE] [int] NOT NULL PRIMARY KEY,
[DESCRIPTION] [varchar] (50))
CREATE TABLE TEST_TABLE2 (
[CODE] [int] NOT NULL PRIMARY KEY,
[DESCRIPTION] [varchar] (50))
go
CREATE VIEW dbo.TEST_VIEW
AS
SELECT CODE,
UPPER(DESCRIPTION) AS DESCRIPTION,
ISNULL(UPPER(DESCRIPTION), 'DEFAULT') DESCRIPTION_DEF
FROM dbo.TEST_TABLE2
go
Now, run this code:
DECLARE cc CURSOR FOR
SELECT TEST_TABLE1.CODE, TEST_VIEW.DESCRIPTION, TEST_VIEW.DESCRIPTION_DEF
FROM TEST_TABLE1 LEFT OUTER JOIN TEST_VIEW
ON TEST_VIEW.CODE = TEST_TABLE1.CODE
FOR UPDATE
For SQL Server 2000 versions before SQL Server 2000 SP2,
with the security hotfix discussed in
Microsoft
Security Bulletin MS02-061
(http://www.microsoft.com/technet/security/bulletin/MS02-061.mspx)
installed, the code runs successfully.
For all SQL Server 2000 versions after SQL Server 2000 SP2,
with the security hotfix discussed in
Microsoft
Security Bulletin MS02-061
(http://www.microsoft.com/technet/security/bulletin/MS02-061.mspx)
installed, the code does not run
successfully.
For SQL Server 2000 versions 8.00.0769 and later, when you
use trace flag -T220 or DBCC traceon (220), the code runs successfully.
Also note that the SELECT statement does not give the same
result.
For SQL Server 2000 versions before SQL Server 2000 SP2,
with the security hotfix discussed in
Microsoft
Security Bulletin MS02-061
(http://www.microsoft.com/technet/security/bulletin/MS02-061.mspx)
installed, or post 8.00.0769 with trace
flag 220, the result is similar to:
For SQL Server 2000 versions after SQL Server 2000 SP2,
with the security hotfix discussed in
Microsoft
Security Bulletin MS02-061
(http://www.microsoft.com/technet/security/bulletin/MS02-061.mspx)
installed, the result is similar
to: