How To Change the Ownership of a Schema in MS SQL Server?
Submitted by: AdministratorIf you want to change the owner of a schema, you can use the "ALTER AUTHORIZATION" statement using the following syntax:
ALTER AUTHORIZATION ON SCHEMA::schema_name TO user_name
The following tutorial example shows you how to change ownership of schema "ggl" to "ggl_user":
-- Login with "sa"
USE GlobalGuideLineDatabase;
GO
ALTER AUTHORIZATION ON SCHEMA::ggl TO ggl_user
GO
SELECT s.name, u.name AS owner
FROM sys.schemas s, sys.database_principals u
WHERE s.principal_id = u.principal_id;
GO
<pre>name owner
------------------- --------------------
dbo dbo
ggl ggl_User
guest guest
...</pre>
Submitted by: Administrator
ALTER AUTHORIZATION ON SCHEMA::schema_name TO user_name
The following tutorial example shows you how to change ownership of schema "ggl" to "ggl_user":
-- Login with "sa"
USE GlobalGuideLineDatabase;
GO
ALTER AUTHORIZATION ON SCHEMA::ggl TO ggl_user
GO
SELECT s.name, u.name AS owner
FROM sys.schemas s, sys.database_principals u
WHERE s.principal_id = u.principal_id;
GO
<pre>name owner
------------------- --------------------
dbo dbo
ggl ggl_User
guest guest
...</pre>
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Create a Testing Table with Test Data in MS SQL Server? |
☺ | How To Get the Definition of a View Out of the SQL Server? |
☺ | What Happens If Strings Are Casted into Wrong Code Pages in MS SQL Server? |
☺ | Can You Roll Back the DDL Statement in a Trigger? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |