I accidentally changed the DB owner to SA. Is there logging that would show what the previous开发者_StackOverflow社区 DB owner was?
Thanks.
The database owner is stored in the master database (sysdatabases
or sys.databases
table; please always mention your version of SQL Server). So you could restore a backup of the master database to a new instance of SQL Server, query the old owner and set it back on your production instance.
It would also be interesting to know why the database owner is important to you. In most environments I've seen, all databases are owned by sa and users who need database owner permissions are added to the db_owner role explicitly. This is a better way to handle permissions, because only one login can be the database owner, but multiple users can have database owner permissions. Therefore, using the db_owner role is more flexible.
精彩评论