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 3236114
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:35:04+00:00 2026-05-17T17:35:04+00:00

I have a table (DB_TableInfo) in my DB like the following TableId Type 859374678

  • 0

I have a table (DB_TableInfo) in my DB like the following

TableId         Type
859374678        R
579845658        B
478625849        R
741587469        E
.
.
.

this table represents all tables in my DB. What I wanna do is to write a query to select tables of Type ‘R’, get their Id and return the Name of the table belonging to that Id (the TableName column is not available in the specified table)

Can anybody help me out?

I wanna write a query similar to this one!

SELECT TableID = OBJECT_NAME FROM [DB_TableInfo] WHERE Type = 'R' 
  • 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-17T17:35:04+00:00Added an answer on May 17, 2026 at 5:35 pm

    From the mention of sys.objects and use of square brackets I assume you are on SQL Server.

    You can use the object_name function.

    SELECT OBJECT_NAME(TableID) /*Might match objects that aren't tables as well though*/
     FROM [DB_TableInfo] 
     WHERE Type = 'R' 
    

    Or join onto sys.tables

    SELECT T.name
     FROM [DB_TableInfo] D 
     join sys.tables T ON D.TableID = T.object_id
     WHERE D.Type = 'R' 
    

    And to exclude empty tables

    SELECT t.name
    FROM DB_TableInfo d 
    JOIN sys.tables t ON d.TableId = t.object_id
    JOIN sys.dm_db_partition_stats ps ON ps.object_id = t.object_id
    WHERE d.Type = 'R' and ps.index_id <= 1
    GROUP BY d.TableId, t.name
    HAVING SUM(ps.row_count) > 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 9 table db set up like this. TableA acct_id TableB tabB_id
I have this table: and I want to display all friend names are without
I have a db table containing a column display_order . The data looks like
In a DB table I have several fields with datetime as field type. So
I have this table user_id time_completed 4 86.30887 5 57.81364 5 35.50281 5 10.00000
I have this table user_id time_completed 4 86.30887 5 57.81364 5 35.50281 5 10.00000
i have a table name preferences under this there are multiple columns but i
:I have this table: id | name | chapter | book 1 hamlet I
I have a large table and I'd like to store the results in Memcache.
I have db table which has location details like postal code, long/lat data, region,

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.