Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of all tables in database

Tags:

sql

sql-server

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

like image 487
RShar Avatar asked May 12 '11 19:05

RShar


1 Answers

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.

like image 184
YetAnotherUser Avatar answered Sep 19 '22 10:09

YetAnotherUser