Home > Archive > MS SQL Server > November 2006 > Changing owner of DB objects









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Changing owner of DB objects
Gav

2006-11-16, 5:20 am

I have a database where all objects within it and owned by a user not dbo.
Is there any way I can change all the object ownerships to dbo? I'm talking
thousands of objects so I'm thinking some form of script.

thanks

Gav


Uri Dimant

2006-11-16, 5:20 am

Gav
SELECT 'EXEC sp_changeobjectowner
'''+ROUTINE_NAME+'''
,''dbo'''
FROM INFORMATION_SCHEMA.ROUTINES
WHERE OBJECTPROPERTY(OBJEC
T_ID(ROUTINE_SCHEMA+
'.'+ROUTINE_NAME),
'IsMsShipped')=0
AND ROUTINE_SCHEMA != 'dbo'




"Gav" <gav@nospam.com> wrote in message
news:455c2cce$0$696$
88260bb3@news.teranews.com...
>I have a database where all objects within it and owned by a user not dbo.
>Is there any way I can change all the object ownerships to dbo? I'm talking
>thousands of objects so I'm thinking some form of script.
>
> thanks
>
> Gav
>



Tibor Karaszi

2006-11-16, 5:21 am

What version of SQL Server?

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/



"Gav" <gav@nospam.com> wrote in message news:455c2cce$0$696$
88260bb3@news.teranews.com...
>I have a database where all objects within it and owned by a user not dbo. Is there any way I can
>change all the object ownerships to dbo? I'm talking thousands of objects so I'm thinking some form
>of script.
>
> thanks
>
> Gav
>



Gav

2006-11-16, 5:21 am

Sorry, forgot the obvious. :o) 2000 SP3a.

"Tibor Karaszi" <tibor_please.no. email_karaszi@hotmai
l.nomail.com> wrote in
message news:eVnJq0WCHHA.3604@TK2MSFTNGP03.phx.gbl...
> What version of SQL Server?
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www. solidqualitylearning
.com/

>
>
> "Gav" <gav@nospam.com> wrote in message
> news:455c2cce$0$696$
88260bb3@news.teranews.com...
>
>



Tibor Karaszi

2006-11-16, 5:21 am

See Uri's post (sp_changeobjectowne
r).

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/



"Gav" <gav@nospam.com> wrote in message news:455c42c8$0$709$
88260bb3@news.teranews.com...
> Sorry, forgot the obvious. :o) 2000 SP3a.
>
> "Tibor Karaszi" <tibor_please.no. email_karaszi@hotmai
l.nomail.com> wrote in message
> news:eVnJq0WCHHA.3604@TK2MSFTNGP03.phx.gbl...
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com