locked
How to get all the table names inside the database by T-SQL statement? RRS feed

  • Question

  • How to get all the table names inside the database by  T-SQL statement?

    Thanks.
    Wednesday, May 13, 2009 6:27 PM

Answers

  • I think he means that if you're in a case-sensitive environment, you have to do a

    select * from INFORMATION_SCHEMA.TABLES   --the name of the view has to be in all uppercase

    --Brad
    • Marked as answer by Jake Wardley Thursday, May 14, 2009 12:46 AM
    Wednesday, May 13, 2009 7:13 PM

All replies

  • try:

    select *
    from sys.tables

    select *
    from sys.objects
    where [type] = 'U'

    select *
    from information_schema.tables;


    AMB
    • Proposed as answer by NimitPParikh Wednesday, May 13, 2009 6:39 PM
    Wednesday, May 13, 2009 6:28 PM
  • SELECT Table_Schema, Table_Name FROM Information_Schema.Tables;
    Wednesday, May 13, 2009 6:28 PM
  • Personally, I recommend catalog views (as of 2005), i.e., sys.tables. And just as a sidenote, the information schema views are all in uppercase. If one work in a case-sensitive instance one need to get case right for object names...
    Tibor Karaszi
    Wednesday, May 13, 2009 6:54 PM
  • TABLE names are case-sensitive when not enclosed?
    Wednesday, May 13, 2009 6:57 PM
  • I think he means that if you're in a case-sensitive environment, you have to do a

    select * from INFORMATION_SCHEMA.TABLES   --the name of the view has to be in all uppercase

    --Brad
    • Marked as answer by Jake Wardley Thursday, May 14, 2009 12:46 AM
    Wednesday, May 13, 2009 7:13 PM
  • Thanks Brad. Yes, that is what I meant. And, also, our own objects names (tables, columns, views, procedures, variables etc) are case sensitive in a case sensitive environment.
    Tibor Karaszi
    Wednesday, May 13, 2009 7:15 PM
  • Thanx for the info. I did not know that.
    Thursday, May 14, 2009 12:28 PM