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

  • Home
  • SEARCH
  • 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 4332146
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:12:54+00:00 2026-05-21T10:12:54+00:00

How to get the list of the tables in my sql-server database that do

  • 0

How to get the list of the tables in my sql-server database that do not have any records in them?

  • 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-05-21T10:12:55+00:00Added an answer on May 21, 2026 at 10:12 am

    On SQL Server 2005 and up, you can use something like this:

    ;WITH TableRows AS
    (
       SELECT 
          SUM(row_count) AS [RowCount], 
          OBJECT_NAME(OBJECT_ID) AS TableName
       FROM 
          sys.dm_db_partition_stats
       WHERE 
          index_id = 0 OR index_id = 1
       GROUP BY 
          OBJECT_ID
    )
    SELECT *
    FROM TableRows
    WHERE [RowCount] = 0
    

    The inner select in the CTE (Common Table Expression) calculates the number of rows for each table and groups them by table (OBJECT_ID), and the outer SELECT from the CTE then grabs only those rows (tables) which have a total number of rows equal to zero.

    UPDATE: if you want to check for non-Microsoft / system tables, you need to extend the query like this (joining the sys.tables catalog view):

    ;WITH TableRows AS
    (
       SELECT 
           SUM(ps.row_count) AS [RowCount], 
           t.Name AS TableName
       FROM 
           sys.dm_db_partition_stats ps
       INNER JOIN
           sys.tables t ON t.object_id = ps.object_id
       WHERE 
           (ps.index_id = 0 OR ps.index_id = 1)
           AND t.is_ms_shipped = 0
       GROUP BY 
           t.Name
    )
    SELECT *
    FROM TableRows
    WHERE [RowCount] = 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get list of all tables in SQL Server database using query.
I have a web application that loads some 50 tables from SQL Server into
I have a legacy SQL Server 2000 database that has one column that has
I need to get a list of all tables that are published for replication
How do I get a list of all the tables defined for the database
How do you get a list of all the tables and use that list
I have a database table in Sql Server 2008 R2 which contains data stored
I'm working with a SQL Server 2000 database that likely has a few dozen
I have a huge database with 100's of tables and stored procedures. Using SQL
I am trying to map a SQL Server database with nHibernate that is full

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.