SQL 你如何在sql中更改数据库的所有者?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/565780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:11:21  来源:igfitidea点击:

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

sqlsql-server

提问by Ryan

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.

在管理工作室中,您可以在属性下看到所有者,但它不会让您更改它。我的猜测是有一些存储过程可以更改它,而您无法通过 gui 进行更改。

回答by Quassnoi

Surpisingly, it's called sp_changedbowner.

令人惊讶的是,它被称为sp_changedbowner

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

你实际上可以在SQL Server Management Studio下面改变它Database / Properties / Files

回答by user353gre3

In addition to using SSMSGUI, you can also use ALTER AUTHORIZATIONor alternately use sp_changedbownerstatement.

除了使用SSMSGUI,您还可以使用ALTER AUTHORIZATION或交替使用sp_changedbowner语句。

ALTER AUTHORIZATION ON DATABASE::MyDatabaseName TO NewOwner;
GO

Please note sp_changedbowneris deprecated from SQL Server 2012.

请注意sp_changedbownerSQL Server 2012.

回答by SqlACID

Actually you can change it in SSMS, it's in the Files tab on the database properties.

实际上,您可以在 SSMS 中更改它,它位于数据库属性的“文件”选项卡中。