SQL SERVER – 2005 List All Tables of Database

This is very simple and can be achieved using system table sys.tables.

USE YourDBName
GO

SELECT
*
FROM sys.Tables
GO

This will return all the tables in the database which user have created.

Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL

SQL Scripts, SQL System Table
Previous Post
SQL SERVER – Explanation and Example Four Part Name
Next Post
SQL SERVER – Running Batch File Using T-SQL – xp_cmdshell bat file

Related Posts

448 Comments. Leave new

  • Thanks for your help but i am looking something like where i can display the list of database . Please anybody help me to listing of database in sql 2005.

    Reply
  • Hi,
    Thanks this helped me.
    can anyone tell me how to see only the user defined tables or
    stored procedures or views or functions in a given database ?

    Reply
    • 1) select distinct type from sysobjects.
      2) using for user table use
      select distinct type from sysobjects type=’u’
      for procedures type=’p’ etc….

      Reply
  • Thanks
    Thanks a lot!!!!!!!!!!!!!!

    Reply
  • dear sir,
    i want to know how to see the structure of table……..
    In oracle desc tablename means it will show the structure of that particular table but the sql server it is not show ………
    i need solution for this question as early as possible …..
    advance thanks ………. please consider as a urgent…..

    Reply
  • Suresh,
    to view the structure of the table in MS SQL Server
    try this

    Solution: sp_help tableName

    Thanks,
    Venky

    Reply
    • and how you can see the structure of all tables of a specific database?

      thanks in advance for your reply

      Reply
  • I want to see all the data in all the tables in a database using the least code possible !!! Please let me know ASAP…

    Reply
  • how many user using my db
    (same user) ?

    Reply
  • thaink you
    what about
    only user tables?

    Reply
  • I got much information regarding the database list of objects

    Thank you
    Harinath

    Reply
  • AbhishekGupta
    April 17, 2008 9:06 pm

    I am not getting abt master table.

    Reply
  • Thank you. Helps a lot :)

    Reply
  • How could i get all the data from all the table of the specific database?

    Thanks a lot in advance!

    Reply
    • This will generate the query for you

      select ‘select * from ‘+table_name from information_schema.tables
      where table_type=’BASE TABLE’

      Reply
  • Querry to fetch all tables in a database:

    select * from sysobjects where type=’u’
    ————————————————–
    Querry to fetch all procedures in a database:

    select * from sysobjects where type=’p’

    Regards
    Rap…

    Reply
  • to view all tables……

    SELECT * FROM TAB;

    this will work…….

    Reply
  • Dear sir,

    How do i get all databases in sql server

    Regard’s

    pushparaj

    Reply
  • Dear Friends,

    I want to know how to get all table name from particular data base in sql server 2005.

    Thanks.

    Reply
    • u can get all the tables by using the comman

      select * from sys.objects where type=’u’ (in sql server)
      and
      select * from tab (in oracle)

      Reply
  • Hi ,

    I am creating an application where I have to list all the servers and on selecting any server the combobox should dynamically have all the databases that are present on that server so that the user can select any one of them. Can anyone please help. its urgent!!!

    thanks,
    Gaurav

    Reply
  • @Kaushal
    I want to know how to get all table name from particular data base in sql server 2005.

    select * from sysobjects where xtype=’U’

    Reply
  • if i want to check the primary and foreign key relations of particular table is it possible….if there is any solution plz tell me……..

    thx in advance

    Regards,
    Rekha…

    Reply
    • Primary key informations

      EXEC sp_pkeys ‘table name’

      Foreign key informations

      EXEC sp_fkeys ‘table name’

      Reply
  • I need to display only user defined tables from the current database.

    Reply

Leave a Reply