473,653 Members | 3,000 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table Corruption?

I have a table in my database called Users:

CREATE TABLE [Users] (
[UserID] [uniqueidentifie r] NOT NULL CONSTRAINT [DF_Users_UserID]
DEFAULT (newid()),
[UserName] [nvarchar] (20) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NOT
NULL ,
[password] [nvarchar] (40) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NOT
NULL ,
[EmailAddress] [nvarchar] (100) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS
NOT NULL ,
[ValidFrom] [datetime] NOT NULL ,
[ValidTo] [datetime] NULL ,
[passwordSalt] [bigint] NOT NULL ,
[FullName] [nvarchar] (200) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NOT
NULL ,
[CreatorUserID] [uniqueidentifie r] NOT NULL ,
[DeletorUserID] [uniqueidentifie r] NULL ,
CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED
(
[UserID],
[]
) ON [PRIMARY] ,
CONSTRAINT [UX_Users_UserNa me] UNIQUE NONCLUSTERED
(
[UserName]
) ON [PRIMARY] ,
CONSTRAINT [FK_Users_UsersC reator] FOREIGN KEY
(
[CreatorUserID]
) REFERENCES [Users] (
[UserID]
),
CONSTRAINT [FK_Users_UsersD eletor] FOREIGN KEY
(
[DeletorUserID]
) REFERENCES [Users] (
[UserID]
),
CONSTRAINT [CK_Users_Finish ed] CHECK ([ValidTo] is null and
[DeletorUserID] is null or ((not([ValidTo] is null))) and
((not([DeletorUserID] is null)))),
CONSTRAINT [CK_Users_ValidD ates] CHECK ([ValidFrom] <= [ValidTo])
) ON [PRIMARY]
GO

If you're looking at the Primary Key constraint above, you can probably
already see the problem (this script was produced by Query Analyzer).
If I try to get query analyzer to just script the PK, I get the
following error message:

[SQL-DMO]The name '' is not a valid object identifier, or is not a
valid format for this property or method.

I've googled for this phrase, and cannot locate it. If I drop all of
the constraints in my database, and reapply the constraints to Users
using the following script:

alter table Users add constraint
DF_Users_UserID DEFAULT NEWID() FOR UserID
go
alter table Users add constraint
PK_Users PRIMARY KEY
(
UserID
) on [PRIMARY]
go
alter table Users add constraint
UX_Users_UserNa me UNIQUE
(
UserName
)
go
alter table Users add constraint
CK_Users_ValidD ates CHECK
(
ValidFrom <= ValidTo
)
go
alter table Users add constraint
CK_Users_Finish ed CHECK
(
(
ValidTo is null and
DeletorUserID is null
)
or
(
not ValidTo is null and
not DeletorUserID is null
)
)
go
alter table Users add constraint
FK_Users_UsersC reator FOREIGN KEY
(
CreatorUserID
)
REFERENCES Users
(
UserID
)
go
alter table Users add constraint
FK_Users_UsersD eletor FOREIGN KEY
(
DeletorUserID
)
REFERENCES Users
(
UserID
)
go

I *still* have this wierd PK. I've checked through both the
INFORMATION_SCH EMA views and directly through the system tables, and so
far as they are concerned there is only a single column (UserID) acting
as part of the PK.

So, any ideas? It appears to be preventing us from setting up
replication. Thankfully, it also occurs in a restored backup of the DB,
so I'll be able to reproduce/attempt fixes to my hearts content.

Thanks,

Damien

Jul 23 '05 #1
10 2019
Damien (Da************ *******@hotmail .com) writes:
I *still* have this wierd PK. I've checked through both the
INFORMATION_SCH EMA views and directly through the system tables, and so
far as they are concerned there is only a single column (UserID) acting
as part of the PK.
Exactly which system table did you check? sysindexkeys should be the one.

If you do

SELECT * FROM syscolumns WHERE id = object_id('User s') ORDER BY colid

Are the colid sequential from 1 and up? (My guess is that there is a
history of a dropped column involved.)
So, any ideas? It appears to be preventing us from setting up
replication. Thankfully, it also occurs in a restored backup of the DB,
so I'll be able to reproduce/attempt fixes to my hearts content.


DBCC CHECKCATALOG could be worth trying.

As simple fix may be to rename the table, create a new and move data
over.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2
Sorry, posting through new Google, can't seem to find an option to
include the previous replies, so this will seem a little
discontinuous.. .

I did indeed check sysindexkeys (and the relevant INFORMATION_SCH EMA
view - can't remember which it is. I'm kind of naughty, I always head
straight for the tables)

Checking syscolumns the colids are, indeed, strictly increasing and
continuous. The database design is only a few months old, I'm the only
developer of it, and although it has evolved (checking history
here...), I've never dropped any columns from it.

One thing I've started wondering... There is another table in the
database with the following:

CREATE TABLE [CreditorService s].[Users] (
[UserID] [uniqueidentifie r] NOT NULL ,
[AbstractCredito rID] [uniqueidentifie r] NOT NULL ,
CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED
(
[UserID],
[AbstractCredito rID]
) WITH FILLFACTOR = 90 ON [PRIMARY] ,
CONSTRAINT [FK_Users_Abstra ctCreditors] FOREIGN KEY
(
[AbstractCredito rID]
) REFERENCES [AbstractCredito rs] (
[AbstractCredito rID]
),
CONSTRAINT [FK_Users_Users] FOREIGN KEY
(
[UserID]
) REFERENCES [Users] (
[UserID]
)
) ON [PRIMARY]
GO

SQL Server shouldn't get confused with having two tables with the same
name, should it? They do have separate owners (the original being under
the dbo role).

Jul 23 '05 #3
Doh! The Primary Keys have the same name, and it's this that seems to
be confusing Query Analyzer. Hopefully, that was what was confusing
replication as well

Jul 23 '05 #4
Damien (Da************ *******@hotmail .com) writes:
Doh! The Primary Keys have the same name, and it's this that seems to
be confusing Query Analyzer. Hopefully, that was what was confusing
replication as well


Interesting. As far as QA is concerned I guess it is beyond hope, since
it replaced with a new tool in SQL 2005. The same applies to DMO which is
the real culprit.

Then again, when I come home I will test the case in SQL 2005, to see that
the problem does not reappear there.

If this a problem for replication as well, it would be interesting to see a
repro. The problem in this case is that I'm not into replicaiton myself, so
I would need some more instructions.

Since SQL 2005 introduces "real" schemas, these sort of collisions are
much more likely to appear in SQL 2005.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #5

Erland Sommarskog wrote:
Damien (Da************ *******@hotmail .com) writes:
Doh! The Primary Keys have the same name, and it's this that seems to be confusing Query Analyzer. Hopefully, that was what was confusing
replication as well
Interesting. As far as QA is concerned I guess it is beyond hope,

since it replaced with a new tool in SQL 2005. The same applies to DMO which is the real culprit.

Then again, when I come home I will test the case in SQL 2005, to see that the problem does not reappear there.

If this a problem for replication as well, it would be interesting to see a repro. The problem in this case is that I'm not into replicaiton myself, so I would need some more instructions.

Since SQL 2005 introduces "real" schemas, these sort of collisions are much more likely to appear in SQL 2005.

Well, we've tried and failed to get replication working - it's
confusing itself over the table owners (of which there are a large
number), so we're going to have to cobble together our own solution.
Yippee.

<gripe not-aimed-at="Erland">Is it too much to ask that Microsoft
deliver a replication solution that actually works in slightly unusual
situations? I wouldn't have thought having alternate owners would be
*that* uncommon.</gripe>

Jul 23 '05 #6
Damien (Da************ *******@hotmail .com) writes:
Well, we've tried and failed to get replication working - it's
confusing itself over the table owners (of which there are a large
number), so we're going to have to cobble together our own solution.
Yippee.
I have been trying to recreate the scripting error, using the table
scripts you have posted, but I have not been successful. That is, the
tables are scripted correctly. There could be three reasons for this:

1) I had to omit FK constraints to tables that I have don't have.
2) I am running SP4 Beta of SQL Server, and the bug has actually been
fixed.
3) My scripting options in QA are not the default ones.

The second seem to be the most likely to me. I would encourage you to get
access to the beta, and see if helps your problem. See
http://support.microsoft.com/kb/290211 for information about the SP4
beta.

If you get the problem with SP4 beta as well, I'd be interested to have a
complete script to build a database that demonstrates the problem. That
is, CREATE DATABASE, sp_addlogin, sp_adduser, CREATE TABLE etc. No, I
don't want your entire database. Just as much that the problem occurs.
In such case, I could bring it up with Microsoft. As I said, fixes to
DMO and Query Analyzer are unlikely, but replication bugs are more likely
to be fixed. And in any case, tests on SQL 2005 would be very interesting
to do.
<gripe not-aimed-at="Erland">Is it too much to ask that Microsoft
deliver a replication solution that actually works in slightly unusual
situations? I wouldn't have thought having alternate owners would be
*that* uncommon.</gripe>


Well, to be honest, I completly fail to see the point with having
objects owned by anyone than dbo in SQL 2000. Of course, you can have
dummy users for the schemas, but it's still a mess.

But in SQL 2005, where they have real schemas, it suddenly all make
sense to do things like this.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #7
Erland Sommarskog <es****@sommars kog.se> wrote in message news:<Xn******* *************** @127.0.0.1>...
Damien (Da************ *******@hotmail .com) writes:
Well, we've tried and failed to get replication working - it's
confusing itself over the table owners (of which there are a large
number), so we're going to have to cobble together our own solution.
Yippee.
I have been trying to recreate the scripting error, using the table
scripts you have posted, but I have not been successful. That is, the
tables are scripted correctly. There could be three reasons for this:

1) I had to omit FK constraints to tables that I have don't have.
2) I am running SP4 Beta of SQL Server, and the bug has actually been
fixed.
3) My scripting options in QA are not the default ones.

The second seem to be the most likely to me. I would encourage you to get
access to the beta, and see if helps your problem. See
http://support.microsoft.com/kb/290211 for information about the SP4
beta.


I'll attempt to get hold of it and see if I can reproduce again.

If you get the problem with SP4 beta as well, I'd be interested to have a
complete script to build a database that demonstrates the problem. That
is, CREATE DATABASE, sp_addlogin, sp_adduser, CREATE TABLE etc. No, I
don't want your entire database. Just as much that the problem occurs.
In such case, I could bring it up with Microsoft. As I said, fixes to
DMO and Query Analyzer are unlikely, but replication bugs are more likely
to be fixed. And in any case, tests on SQL 2005 would be very interesting
to do.
I'll try to get the service pack. If that clears it up, all well and
good. Otherwise, I'll try to strip my scripts down to the minimum that
exhibits the problem and post them back here.
<gripe not-aimed-at="Erland">Is it too much to ask that Microsoft
deliver a replication solution that actually works in slightly unusual
situations? I wouldn't have thought having alternate owners would be
*that* uncommon.</gripe>


Well, to be honest, I completly fail to see the point with having
objects owned by anyone than dbo in SQL 2000. Of course, you can have
dummy users for the schemas, but it's still a mess.

But in SQL 2005, where they have real schemas, it suddenly all make
sense to do things like this.


Dummy roles in order to get "schemas" is indeed what is being done
here. It's seemed to work nicely for all my needs up until now.
Looking forward to 2005, but don't think it'll get rolled out at work
for quite some time - we only just upgraded from 7 a couple of months
ago.
Jul 23 '05 #8
Damien (Da************ *******@hotmail .com) writes:
I'll try to get the service pack. If that clears it up, all well and
good. Otherwise, I'll try to strip my scripts down to the minimum that
exhibits the problem and post them back here.
It would great to know whether the service pack is the cure.
Dummy roles in order to get "schemas" is indeed what is being done
here. It's seemed to work nicely for all my needs up until now.
Looking forward to 2005, but don't think it'll get rolled out at work
for quite some time - we only just upgraded from 7 a couple of months
ago.


I know how it is. We were among those that never came around to upgrade
SQL 7. We went directly from 6.5 to SQL 2000.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #9
Erland Sommarskog <es****@sommars kog.se> wrote in message news:<Xn******* *************** @127.0.0.1>...
Damien (Da************ *******@hotmail .com) writes:
I'll try to get the service pack. If that clears it up, all well and
good. Otherwise, I'll try to strip my scripts down to the minimum that
exhibits the problem and post them back here.


It would great to know whether the service pack is the cure.
Dummy roles in order to get "schemas" is indeed what is being done
here. It's seemed to work nicely for all my needs up until now.
Looking forward to 2005, but don't think it'll get rolled out at work
for quite some time - we only just upgraded from 7 a couple of months
ago.


I know how it is. We were among those that never came around to upgrade
SQL 7. We went directly from 6.5 to SQL 2000.


Hi Erland,

The SP seems to fix the problem. I've tried both upgrading the server
with a duff database on it already, and also creating a fresh database
on an SP4 machine, and neither exhibits the bug. Makes me wonder
whether it was the MS03-031 hotfix that introduced the bug. Can anyone
reproduce this on a plain (version 760, I think, rather than 818 which
is an MS03-031 patched box) SP3 box?

create database PK_Problem
go
use PK_Problem
go
create table dbo.Table1 (
A uniqueidentifie r DEFAULT newid() not null
)
go
alter table dbo.Table1 add constraint PK_Table1 PRIMARY KEY (A)
go
create table dbo.Table2 (
B uniqueidentifie r DEFAULT newid() not null
)
go
alter table dbo.Table2 add constraint PK_Table2 PRIMARY KEY (B)
go
sp_addrole 'Boris','dbo'
go
create table Boris.Table1 (
A uniqueidentifie r not null,
B uniqueidentifie r not null
)
go
alter table Boris.Table1 add constraint FK_Table1_Table 1 FOREIGN KEY
(A) REFERENCES dbo.Table1 (A)
go
alter table Boris.Table1 add constraint FK_Table1_Table 2 FOREIGN KEY
(B) REFERENCES dbo.Table2 (B)
go
alter table Boris.Table1 add constraint PK_Table1 PRIMARY KEY (A,B)
go
Jul 23 '05 #10

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

Similar topics

1
5675
by: Thiko | last post by:
Hi I have a corrupt PK index on a table column. It is a unique PK. It needs to be dropped and recreated to cure the corruption. The table is on a backup database which is in replication having records added to it to keep the two databases in sync. Am I correct in think that if I:
0
1744
by: Richard Gabriel | last post by:
Hi everyone, Since we upgraded to MySQL 4.0.13 from 3.23, we have been getting table corruption often. It happens about twice per week (with about 500 queries per second average). I have even set up a cron to run mysqlcheck every hour to try to do some damage control. The biggest problem is that once the table is corrupted, it seems to be locked. Well, no clients can read from it. Once repaired, just one record is usually lost for...
16
21306
by: mamo74 | last post by:
Hello. I am administering a SQL Server (Enterprise Edition on Windows 2003) from some month and can't understand what is going on in the latest week (when the db grow a lot). The DB is around 250G, and has one table with 1 billion rows. It is performing in a decent way, but can't understand why a particolar table has strong performance problem.
14
2363
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
21
2693
by: Dan | last post by:
Hi, just ran into my first instance of a backend Access97 database not compacting. I'm getting the "MSACCESS.EXE has generated errors.." message on compact. I've narrowed it down to the largest table which cotains 600k of records. I've tried copying the database and trying to compact that -doesn't work. I've tried Repair and then compact which also doesn't work. I've tried to create a new database and import the tables but it flakes out...
28
4034
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during the work day. The backend has a table called CLIENTS with approximately 6000 client records. Changes to data in the table are made via a frontend db Form which has CLIENTS as its record source.
4
2707
by: deko | last post by:
I've heard it's best not to have any formatting specified for Table fields (except perhaps Currency), and instead set the formatting in the Form or Report. But what about Yes/No fields? When I create a Yes/No field in a Table the default format is "Yes/No". If I clear or change the Format property in the General Tab (and keep the default "Checkbox" in the Lookup tab), the field still looks the same when I open the table in Datasheet...
3
2002
by: MLH | last post by:
Precise determinations are not the objective. I would lke a single button click approach to creating a report/table/dynaset - whatever - to display each table name and an approx- imation of the number of bytes of storage spaced occupied by the data in each table. I don't remember seeing any discussion on this topic over the years since Access 2.0 and up through the more recent releases.
3
10021
by: Gunnar Nygjerd | last post by:
An Access2003-database was suddenly impossible to open. I got the message "AOIndex is not an index in this table". Same if I try to correct/compress the database. How can I open the database again?
3
2169
by: NEWSGROUPS | last post by:
Is there any way to find out what database object or table was corrupt after a repair has run in Access 2000? If I can find this out I may find out why the corruption is happening. Any help would be appreciated. Thanks, Mark
0
8370
marktang
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...
0
8283
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8590
tracyyun
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...
0
7302
agi2029
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...
1
6160
isladogs
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...
0
4147
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...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.