How To Change the Ownership of a Schema in MS SQL Server?

Submitted by: Administrator
If 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

Read Online MS SQL Server Job Interview Questions And Answers