Friday, March 9, 2012

Ownership of objects

I want to drop a user by running sp_dropuser.
I get this error:
The user owns objects in the database and cannot be dropped.
How do I find the object the user owns?
Thanks,
AntoninHere's a quick way:
select * from sysobjects where uid = user_id('dbo')
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Antonin Koudelka" <Antonin.Koudelka@.fmc.sa.gov.au> wrote in message
news:e1eugC2rEHA.2580@.TK2MSFTNGP15.phx.gbl...
>I want to drop a user by running sp_dropuser.
> I get this error:
> The user owns objects in the database and cannot be dropped.
> How do I find the object the user owns?
> Thanks,
> Antonin
>|||Hi Tibor,
Thanks for your reply.
I ran
select * from sysobjects where uid = user_id('BME054')
It worked. I got view user defined functions and views, one of them
'SerialQuery'.
Then I tried
sp_changeobjectowner 'SerialQuery', 'dbo'
and got this
Object 'SerialQuery' does not exists or is not a valid object for this
platform.
Any idea, suggestion?
Thanks,
Antonin
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:eEViKT4rEHA.3244@.tk2msftngp13.phx.gbl...
> Here's a quick way:
> select * from sysobjects where uid = user_id('dbo')
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Antonin Koudelka" <Antonin.Koudelka@.fmc.sa.gov.au> wrote in message
> news:e1eugC2rEHA.2580@.TK2MSFTNGP15.phx.gbl...
>>I want to drop a user by running sp_dropuser.
>> I get this error:
>> The user owns objects in the database and cannot be dropped.
>> How do I find the object the user owns?
>> Thanks,
>> Antonin
>>
>|||Hi all,
I read the books online and found out I have to do it like this:
sp_changeobjectowner 'BME054.SerialQuery', 'dbo'
It worked OK and then I could drop the user.
Antonin
"Antonin" <Antonin.Koudelka@.fmc.sa.gov.au> wrote in message
news:%23mPi$a$rEHA.868@.TK2MSFTNGP12.phx.gbl...
> Hi Tibor,
> Thanks for your reply.
> I ran
> select * from sysobjects where uid = user_id('BME054')
> It worked. I got view user defined functions and views, one of them
> 'SerialQuery'.
> Then I tried
> sp_changeobjectowner 'SerialQuery', 'dbo'
> and got this
> Object 'SerialQuery' does not exists or is not a valid object for this
> platform.
> Any idea, suggestion?
> Thanks,
> Antonin
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
> in message news:eEViKT4rEHA.3244@.tk2msftngp13.phx.gbl...
>> Here's a quick way:
>> select * from sysobjects where uid = user_id('dbo')
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "Antonin Koudelka" <Antonin.Koudelka@.fmc.sa.gov.au> wrote in message
>> news:e1eugC2rEHA.2580@.TK2MSFTNGP15.phx.gbl...
>>I want to drop a user by running sp_dropuser.
>> I get this error:
>> The user owns objects in the database and cannot be dropped.
>> How do I find the object the user owns?
>> Thanks,
>> Antonin
>>
>>
>

No comments:

Post a Comment