Solved

PK Index owned by different user - how can I fix

Posted on 2006-10-31
4
1,259 Views
Last Modified: 2012-08-13

I have an SQL 2000 database which is "managed" by a third party application.  When we use the application to delete users, it automatically changes the ownership of any tables the deleted user owned to another user.  I can only assume they use sp_changeowner through the backend - i haven't tried running a trace to confirm.

Somewhere along the lines I have two users that now own only the primary key on several tables.  The tables themselves are owned by another user.  Constraints are setup by the 3rd party app which prevent me from deleting and recreating the index, and I don't want to delete the whole table.  

Can anyone suggest a way to change the ownership on the primary key index?  I didn't realize it was even possible to have tables and indexes owned by different people for the same table.

Thanks.
0
Comment
Question by:ehaley
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
gpompe earned 250 total points
Comment Utility
Have you tried with sp_changeobjectowner ?
0
 
LVL 9

Expert Comment

by:gpompe
Comment Utility
You can use sp_helpconstraint  to get the name of the PK
0
 
LVL 11

Expert Comment

by:rw3admin
Comment Utility
honestly this is the first time I am hearing that a table is created by one user and PK is under another user...

query sysreferences and sysindexes tables and you will see what I mean...

rw3admin
0
 
LVL 1

Author Comment

by:ehaley
Comment Utility

gpompe - my original message was a typo, I was using sp_changeobjectowner.  I finally figured the problem out myself.  It appears there was some error when sp_changeobjectowner was run the first time and it did not change the ownership of the primary key index, only the table, so they ended up being owned by different people.  It was not allowing me to change the ownership of either object to either object since each login already owned "part" of the object.  I ended up transferring ownership of the table to a third login, which correctly changed the table and the PK, then I changed it back.  

Thanks for your help.
Jeff
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now