How to find a SQL schema owner name

23 August,2018 by Jack Vamvas

Question: How can I find the owner of a SQL Server schema ?   I want o find the owner through a t-sql solultion , rather than looking through the GUI. 

Answer: To find a schema owner you can use either sys.schema view or the information_schema.schemata. Since SQL 2005,  information_schema.schemata has come into line with sys.schema.     information_schema.schemata returns schemas just from the current database. 

 Find examples of the twp approaches below. If you're using the sys.schemas method, you'll need to use the schema_name() and user_name() functions to extract the names. 

 

use msdb
go 
select schema_name(schema_id) as schemanames,
user_name(s.principal_id) as usernames 
from sys.schemas As s


SELECT schema_name, schema_owner
FROM information_schema.schemata

 Read more on schemas

DROP SCHEMA script for multiple sql database users (SQL Server ...

SQL Server - ALTER SCHEMA (SQL Server DBA)

Object Dependency in SQL Server


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to find a SQL schema owner name


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer