Change DB owner to AD account that is member of sa

  • So I have an AD account that is a member of an AD group that has sa on our SQL 2008 R2 server.

    How can I set the ownership of the DBs on that server to that account, ideally using PoSh + smo (although ALTER AUTHORIZATION is not out of the question)?

    Does it really require an individual SQL login for that AD account?

    Because $DB.SetOwner("Domain\AD_Account") is throwing me an error.

    Thanks,

    P

  • What is the error?

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Exception calling "SetOwner" with "1" argument(s): "Set owner failed for Database DB"

    + $db.SetOwner("[Domain\User]")

  • The online help specifies that for Database.SetOwner the loginName is:

    A String value that specifies the SQL Server logon that is the new database owner.

    i.e. a SQL Server account.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • OK, but that account already owns quite a few DBs, while not having a "personal" login. So I wondered if there was a way.

    Thanks Gary.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply