问题
When use Database Diagrams in a simple database, SQL Server create a dbo.sysdiagrams table in the Table\Systam Tables node (in Microsoft management studio\object explorer). But sysdiagrams table marked as user table in SQL Server. you can get user table by below query.
SELECT *
FROM sys.tables t
WHERE OBJECTPROPERTY(t.object_id,'IsUserTable') = 1
I don't know that sysdiagram table is a system table or is a user table.
Exists microsoft_database_tools_support with value 1 In the extended property of sysdiagram, that determine this table created automatically.
回答1:
System tables are used internally by the SQL Server, they are the same in every user database.
sysdiagrams is not a system table from the server point of view.
But SQL Server Management Studio creates it to store the diagram data, so it also categorizes it as a system table.
You can exclude such kinda system tables using the extended attribute you mentionned.
回答2:
Management Studio utilizes the following in its determination of "System Objects" where "tbl" is sys.tables:
CAST(
case
when tbl.is_ms_shipped = 1 then 1
when (
select
major_id
from
sys.extended_properties
where
major_id = tbl.object_id and
minor_id = 0 and
class = 1 and
name = N'microsoft_database_tools_support')
is not null then 1
else 0
end
AS bit) AS [IsSystemObject]
来源:https://stackoverflow.com/questions/22270328/sql-server-dbo-sysdiagrams-is-a-user-table-or-system-table