473,588 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

easily repeatable index corruption in SQL Server 2000 (8.00.2050,post-sp4)

One of the developers where I work found that some of his code would
regularly cause index corruption in SQL Server 2000, post-sp4.
@@version is 8.00.2050 and I can repeat this, so I can't (re-)apply
the hotfix for KB article 929440.

I know the code is not a good way to do what he's doing, which I
explained to him. But corrupting the index on the table probably
isn't the right reaction for SQL Server.

A script to recreate the error follows (it's a slightly generic
version of what he was doing). You can create the table in tempdb and
drop it when done. You will get a pile of "Missing or invalid key in
index..." errors from the DBCC CHECKTABLE.

USE tempdb
--select @@version

CREATE TABLE dbo.Claim_Payme nt_Simulation (
file_no int NOT NULL,
row_no int NULL,
related_claim_s eq int NULL,
claim_id int NULL,
patient_control _no varchar(30) NULL,
patient_id varchar(100) NULL
(file_no, row_no, related_claim_s eq)

ALTER TABLE dbo.Claim_Payme nt_Simulation ADD CONSTRAINT
XPKClaim_Paymen t_Simulation
UNIQUE CLUSTERED (file_no, row_no, related_claim_s eq) ON [PRIMARY]

dbo.Claim_Payme nt_Simulation (claim_id)


DECLARE @file_no int, @claim_id int, @count int
SET @file_no = 1
SET @count = 1
WHILE @count < 10000 BEGIN
INSERT dbo.Claim_Payme nt_Simulation (file_no, related_claim_s eq,
patient_control _no)
VALUES (@file_no, @count * 2, CAST (@count * 3 AS varchar (8)) + 'A.'
+ CAST (@count * 4 AS varchar) )

SET @count = @count + 1
--DBCC checktable('dbo .Claim_Payment_ Simulation')
DECLARE @file_no int, @claim_id int, @count int
SET @file_no = 1
UPDATE dbo.Claim_Payme nt_Simulation
SET @claim_id =
CASE WHEN CHARINDEX ('.', patient_control _no) = 0
THEN SUBSTRING (patient_contro l_no, 9, 30)
ELSE SUBSTRING (patient_contro l_no, CHARINDEX ('.',
patient_control _no) + 1, 30)
claim_id =
CASE WHEN ISNUMERIC (@claim_id) = 1
CASE WHEN CAST (@claim_id AS bigint) <= 2147483647
THEN @claim_id
ELSE -99999
ELSE -88888
WHERE file_no = @file_no -- HOWEVER, if the where clause is NOT
included in the update statement, there will be no index corruption

DBCC checktable('dbo .Claim_Payment_ Simulation')

TRUNCATE TABLE dbo.Claim_Payme nt_Simulation
--SELECT * FROM dbo.Claim_Payme nt_Simulation
--DROP TABLE dbo.Claim_Payme nt_Simulation
Sep 29 '08 #1
1 3355
(br************ @gmail.com) writes:
One of the developers where I work found that some of his code would
regularly cause index corruption in SQL Server 2000, post-sp4.
@@version is 8.00.2050 and I can repeat this, so I can't (re-)apply
the hotfix for KB article 929440.

I know the code is not a good way to do what he's doing, which I
explained to him. But corrupting the index on the table probably
isn't the right reaction for SQL Server.
I was able to reproduce the error with SQL 2000 SP4. I did not happen
on SQL 2005 SP2. I don't know if there is a later build of SQL 2000
which addresses this. But since there appears to be a workaround, and
SQL 2000 has fallen out of mainstream support, I doubt that this will
ever be fixed in SQL 2000.

Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Sep 29 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000 Personal disk from the SQL Server 2000 Enterprise kit as this is reported here on the MSDN web site to be the version that is supported on Windows XP. In fact so many of you kind people confess to having succeeded in doing it. I have tried...
by: M Wells | last post by:
Hi All, I have a table that currently contains approx. 8 million records. I'm running a SELECT query against this table that in some circumstances is either very quick (ie results returned in Query Analyzer almost instantaneously), or very slow (ie 30 to 40 seconds to return results), and I'm trying to work out how I improve performance. Essentially the query I'm running is nothing more complex than:
by: Chris Halcrow | last post by:
Hi I've spent ALL DAY trying to re-install SQL Server 2000 on Windows XP. I continually get the error 'cannot configure server' just at the end of the installation. I've tried the following: - Removing SQL server from 'Program Files' folder following an unsuccessful attempt to re-install, and entirely removing the registry entry 'HKEY_CURRENT_USER > SOFTWARE > Microsoft > MSSQLServer', as well as the corresponding entry under...
by: uli2003wien | last post by:
Dear group, we are running a SQL-Server Database which is about 30 GB large. The purpose of this database is to contain periodic data from automatic devices which insert values into some tables. Unfortunately most of these tables don't have a key (and a key can only be introduced when the application programmers have changed their software). Tables have this structure
by: Woody Splawn | last post by:
I am asking this question here because I asked this question in the Reporting Services Newsgroup and did not get an answer. Does anyone know if Reporting Services is intended to work in a client/Server or Local machine environment? Based on what I have seen my guess is yes but that is a guess. In some materal it talks about it running on a web server but my supposition is that this does not necessarily mean that it would not make for a...
by: Todd Brewer | last post by:
Windows Server 2000 ASP.NET 2.0 SQL Server 2000 (on a physically seperate server) I moved an ASP.NET 2.0 application from a development server to production, and am getting the following error: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not
by: 001frien | last post by:
How do i find indexes of the columns of all the tables of the datbase...........most importantly in SQL server 2000 Thanks a lot
by: Sam Shaw | last post by:
I have been looking after an MS Access database, using table links to access data in a back-end MDB database. We have recently micrated to a SQL Server 2000 back-end atabase, once again accessing it though table links. I am comfortable with the data side of things (whether through table links or an adodb.recordset). What I am missing, however, is all the useful things you could do to automatically maintain a back-end database from a...
by: Jaros³aw Kozik | last post by:
my database status is suspect - what can I do to rebuilt it ( using enterprise manager or something else ) ? regards IJKK
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.