24

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

enter image description here

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.

enter image description here

2 Answers 2

18

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]
2
  • I need to know how Management Studio was moving what seemed by all other accounts a user table into the system tables branch of the tree. This answered my questions and allowed me to avoid hard coding table names in my scripts. Jul 14, 2015 at 13:08
  • I just checked upon 'sys.objects' on a SQL Server 2014 Oct 12, 2017 at 9:44
12

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.

3
  • 4
    I'm curious about this table. Is not marked as is_ms_shipped on either sys.objects or sys.tables. And any other flag that points towards been a system table are also zero. So how can this be checked?
    – Yaroslav
    Jan 23, 2015 at 10:42
  • @atesio I just copied all the tables other than system tables from one db to another. Is it mandatory that I also copy dbo.sysdiagrams to the new db?
    – J.S. Orris
    Aug 19, 2015 at 18:54
  • 1
    copying dbo.sysdiagrams is not mandatory, this table stored the diagram data (designed within SQL Server Management Studio, no other use than documentation of your model). If you want the diagrams transferred you can copy the contents of this table, diagrams will then be viewable on the target database. Aug 20, 2015 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.