I'm running this SQL :
SELECT S.name as Owner, T.name as TableName FROM sys.tables AS T
JOIN sys.schemas AS S ON S.schema_id = T.schema_id
And the result is:
Owner TableName
------------------------
dbo Person
dbo Customer
dbo sysdiagrams
sysdiagrams
is a system table
but showed in result.
Update: Thanks all for your answers and comments, I'm using Nate Bolam & vmvadivel answers:
SELECT S.name as Owner, T.name as TableName
FROM
sys.tables AS T
INNER JOIN sys.schemas AS S ON S.schema_id = T.schema_id
LEFT JOIN sys.extended_properties AS EP ON EP.major_id = T.[object_id]
WHERE
T.is_ms_shipped = 0 AND
(EP.class_desc IS NULL OR (EP.class_desc <>'OBJECT_OR_COLUMN' AND
EP.[name] <> 'microsoft_database_tools_support'))
SSMS uses an extended property to mark the sysdiagrams table as a sort of pseudo system table.
Try this:
SELECT S.name as Owner, T.name as TableName FROM sys.tables AS T
INNER JOIN sys.schemas AS S ON S.schema_id = T.schema_id
LEFT JOIN sys.extended_properties AS EP ON EP.major_id = T.[object_id]
WHERE (EP.class_desc IS NULL
OR (EP.class_desc <> 'OBJECT_OR_COLUMN'
AND EP.[name] <> 'microsoft_database_tools_support'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With