Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how Do I list all table names in SQL Server using T-SQL?

SELECT name FROM sys.databases  -- this can list all database name in the server


user database
SELECT * FROM INFORMATION_SCHEMA.TABLES  
     -- these two line can list the table for one particular database 

But how can I output the results like below?

Database              Table
---------             -------------
db1                    t1
db1                    t2
db2                    t1
...                    ...
like image 776
jojo Avatar asked Mar 16 '10 17:03

jojo


People also ask

How can I see all table names in SQL Server?

In MySQL, there are two ways to find the names of all tables, either by using the "show" keyword or by query INFORMATION_SCHEMA. In the case of SQL Server or MSSQL, You can either use sys. tables or INFORMATION_SCHEMA to get all table names for a database.

How do I list all the tables in my database?

To use the SHOW TABLES command, you need to log on to the MySQL server first. On opening the MySQL Command Line Client, enter your password. Select the specific database. Run the SHOW TABLES command to see all the tables in the database that has been selected.

How can I see tables in SQL Server?

Using SQL Server Management Studio In Object Explorer, select the table for which you want to show properties. Right-click the table and choose Properties from the shortcut menu. For more information, see Table Properties - SSMS.


1 Answers

sp_msforeachdb 'select "?" AS db, * from [?].sys.tables'
like image 164
JonH Avatar answered Oct 02 '22 12:10

JonH