TSQL methods to display the owner of schema in a database.

Published 15 August 07 02:23 AM | SQL Master 

You can use 2 methods to get information about owner of a particular schema or set of schema(s) within the database.

Using INFORMATION_SCHEMA views method (which I prefer most of the times): 

USE <DBName>
GO
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA

Using query against system catalog:

SELECT s.name AS 'Schema Name', db.name AS 'Database User Name' , svr.name AS 'SQL Server Login Name'
FROM sys.schemas s
   INNER JOIN sys.database_principals db       ON s.principal_id = db.principal_id
   INNER JOIN sys.server_principals svr           ON db.sid = svr.sid
WHERE s.name = 'SchemaName'

Comments

# Other SQL Server Blogs around the Web said on August 15, 2007 2:40 AM:

You can use 2 methods to get information about owner of a particular schema or set of schema(s) within

# SSQA.net - SqlServer-QA.net said on August 15, 2007 3:00 AM:

You can use 2 methods to get information about owner of a particular schema or set of schema(s) within

Anonymous comments are disabled

About SQL Master

**__________________________________** SQL Server MVP, Sr. DBA & industry expert. - Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it. It is also a power and you will gain by sharing it.

Search

Go

This Blog

«August 2007»
SMTWTFS
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

Syndication