+ Reply to Thread
Results 1 to 3 of 3

Thread: exclude a system table

  1. #1

    exclude a system table

    i am using this query :
    Code:
    SELECT S.name as BelongsTo , T.name as Table FROM  sys.tables AS T
    JOIN sys.schemas AS S ON S.schema_id = T.schema_id
    and the result is :
    Code:
    BelongsTo      Table
    --------------------------
    dbo            Staff
    dbo            Customer
    dbo            sysdiag
    sysdiag is a system table , i don`t know how it got in here .

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    40
    This should fix it:
    Code:
    SELECT S.name as BelongTo, T.name as Table 
    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'))
    hope this is the answer for you

  3. #3
    thank you , it definitely worked

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts