Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7736517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:45:09+00:00 2026-06-01T07:45:09+00:00

Using the stored procedure sp_msforeachtable it’s possible to execute a script for all tables

  • 0

Using the stored procedure sp_msforeachtable it’s possible to execute a script for all tables in a database.

However, there are system tables which I’d like to exclude from that. Instinctively, I would check the properties IsSystemTable or IsMSShipped. These don’t work like I expect – I have for example a table called __RefactorLog:

System table

But when I query if this is a system or MS Shipped table, SQL Server reports none of my tables are system tables:

exec (N'EXEC Database..sp_msforeachtable "PRINT ''? = '' + CAST(ObjectProperty(Object_ID(''?''), ''IsSystemTable'') AS VARCHAR(MAX))"') AS LOGIN = 'MyETLUser'
-- Results of IsSystemTable:
[dbo].[__RefactorLog] = 0
[schema].[myUserTable] = 0

and

exec (N'EXEC Database..sp_msforeachtable "PRINT ''? = '' + CAST(ObjectProperty(Object_ID(''?''), ''IsMSShipped'') AS VARCHAR(MAX))"') AS LOGIN = 'MyETLUser'

-- Results of IsMSShipped:
[dbo].[__RefactorLog] = 0
[schema].[myUserTable] = 0

When I look into the properties of the table (inside SSMS), the table is marked as a system object. An object property like IsSystemObject doesn’t exist though (AFAIK).

How do I check if a table is a system object, apart from the object property? How does SSMS check if a table is a system object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:45:10+00:00Added an answer on June 1, 2026 at 7:45 am

    Management studio 2008 seems to run some quite ugly following code when opening the “System Tables” folder in the object explorer, the key bit seems to be:

    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]
    

    (Where tbl is an alias for sys.tables)

    So it seems that it’s a combination – either is_ms_shipped from sys.tables being 1, or having a particular extended property set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

By edict, we're using stored procedures for all interactions with our database. By organizational
I've been using the sp_MSforeachtable built-in stored procedure to determine the row count of
I'm trying to execute a simple stored procedure with Spring/Hibernate using Annotations. Here are
In this stored procedure I want to get list of all the tables of
Using a stored procedure i have a fairly complex SQL statement which returns a
I am using cursor in a stored procedure and there is no other way
Now I am using one database table to another database stored procedure normally (
Using MS SQL Server .I have made a Stored Procedure named SP_Get_CallsLogged . I
Guys, I am using SQL Server 2000 and executing the sp_columns stored procedure to
I'm curious about people's approaches to using stored procedures in a database that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.