How to change the owners of all db's to sa from unknown

  • How to change the owners of all db's to sa from unknown

    is there any script for that..

    are there any commands?

    thanks in advance

  • If you are sure you want to do that............

    select 'alter authorization on database::['+name+'] to [sa]'

    from master.sys.databases where database_id > 4 -- DO NOT change ownership of system databases

    ---------------------------------------------------------------------

Viewing 2 posts - 1 through 1 (of 1 total)

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