Wednesday, March 20, 2013

MSSQL: Get schema owner of database tables

To retrieve a list of schema owner of database tables, try the following code snippet. Hope it help.s

SELECT t.object_id AS 'TableID', t.name AS 'TableName', s.schema_id AS 'SchemaID', s.name AS 'SchemaOwner'
FROM sys.tables t inner join sys.schemas s ON t.schema_id = s.schema_id
ORDER by t.name

No comments:

Post a Comment

Do provide your constructive comment. I appreciate that.