Sunday, February 12, 2012

Changing DB Owner

Inadvertantly I moved several DB's from one SQL box to another however when
I reattached the DB's onte Target server I was logged in as the incorrect
user so the DB Owner shows up as my personal login and not the
Domain\SQLAdmin user which we are supposed to perform maintanence under
(oops). I suspect things worked because my login ID is domain admin. I did
find the command sp_changedbowner however I think it only works with SQL
users and not Windows Domain users. If this is correct could some one
please send/post the exact syntax to change the DB owner from Domain\mylogin
to Domain\SQLAdmin? Thanks!sp_changedbowner ought to work with both Windows and SQL logins. The
specified login must not already be a user in the database. Examples below.
--standard login
USE MyDatabase
EXEC sp_changedbowner 'SQLAdmin'
--Windows login
USE MyDatabase
EXEC sp_changedbowner 'Domain\SQLAdmin'
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Mike B." <Autobahn97@.hotmail.com> wrote in message
news:e$ytVNFhEHA.3428@.TK2MSFTNGP11.phx.gbl...
> Inadvertantly I moved several DB's from one SQL box to another however
when
> I reattached the DB's onte Target server I was logged in as the incorrect
> user so the DB Owner shows up as my personal login and not the
> Domain\SQLAdmin user which we are supposed to perform maintanence under
> (oops). I suspect things worked because my login ID is domain admin. I
did
> find the command sp_changedbowner however I think it only works with SQL
> users and not Windows Domain users. If this is correct could some one
> please send/post the exact syntax to change the DB owner from
Domain\mylogin
> to Domain\SQLAdmin? Thanks!
>

No comments:

Post a Comment