Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query a list of all tables in a database.

Author  Topic 

sfjtraps
Yak Posting Veteran

65 Posts

Posted - 2014-03-05 : 18:00:36
I'm running SQL Server 2012 Express. I need to query a database and return the list of tables in the database. Can someone please help me construct this query?

Thank you,

sfjtraps

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-03-05 : 18:33:12
http://stackoverflow.com/questions/175415/how-do-i-get-list-of-all-tables-in-a-database-using-tsql
Go to Top of Page

sfjtraps
Yak Posting Veteran

65 Posts

Posted - 2014-03-05 : 18:54:55
Got it......answer is:

SELECT * FROM information_schema.tables
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-03-06 : 06:39:05
Another method

EXEC sp_tables

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2014-03-06 : 07:08:18
how about
select name from sys.tables 
where type = 'U'









How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Go to Top of Page
   

- Advertisement -