简体   繁体   中英

How do you change the owner of a database in sql?

In management studio you can see the owner under properties but it won't let you change it. My guess is there's some stored procedure to change it and you can't do it through the gui.

Surpisingly, it's called sp_changedbowner .

You can actually change it in SQL Server Management Studio under Database / Properties / Files

In addition to using SSMS GUI, you can also use ALTER AUTHORIZATION or alternately use sp_changedbowner statement.

ALTER AUTHORIZATION ON DATABASE::MyDatabaseName TO NewOwner;
GO

Please note sp_changedbowner is deprecated from SQL Server 2012 .

实际上你可以在SSMS中更改它,它位于数据库属性的Files选项卡中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM