23 August,2018 by Tom Collins
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
This is only a preview. Your comment has not yet been posted.
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.
Posted by: |