How can I get list of all tables in SQL Server database using query. My intention is to dynamically display this on a webpage.
            Asked
            
        
        
            Active
            
        
            Viewed 750 times
        
    2 Answers
11
            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:
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.
        Community
        
- 1
 - 1
 
        YetAnotherUser
        
- 9,156
 - 3
 - 39
 - 53
 
11
            
            
        A more generic way:
Select *
From INFORMATION_SCHEMA.TABLES
Where TABLE_TYPE = 'BASE TABLE'
        Thomas
        
- 63,911
 - 12
 - 95
 - 141