Solved

PK Index owned by different user - how can I fix

Posted on 2006-10-31
4
1,277 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
ID: 17845777
Have you tried with sp_changeobjectowner ?
0
 
LVL 9

Expert Comment

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

Expert Comment

by:rw3admin
ID: 17846017
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
ID: 17858073

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

806 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