List of all tables in database

后端 未结 2 1363
离开以前
离开以前 2021-01-11 21:36

How can I get list of all tables in SQL Server database using query. My intention is to dynamically display this on a webpage.

相关标签:
2条回答
  • 2021-01-11 22:10

    A more generic way:

    Select *
    From INFORMATION_SCHEMA.TABLES
    Where TABLE_TYPE = 'BASE TABLE'
    
    0 讨论(0)
  • 2021-01-11 22:12

    Try:

    SELECT [name] from sys.tables
    

    This should give you what you want. You'll then need to call it from your webpage to display in required format.

    You may want to see:

    • How get the names of all the tables from a database in a combo box using c#

    Will probably help you in what you are trying to do.

    Also - you may want to see SQL Server: should I use information_schema tables over sys tables? for sys.tables vs INFORMATION_SCHEMA.

    INFORMATION_SCHEMA is SQL92 standard, but I personally prefer sys.tables in MS-SQL universe as it seems (to me atleast) well structured and have all relevant information, e.g. index information is just not available in INFORMATION_SCHEMA.

    0 讨论(0)
提交回复
热议问题