SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query a list of all tables in a database.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sfjtraps
Yak Posting Veteran

63 Posts

Posted - 03/05/2014 :  18:00:36  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 03/05/2014 :  18:33:12  Show Profile  Reply with Quote
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

63 Posts

Posted - 03/05/2014 :  18:54:55  Show Profile  Reply with Quote
Got it......answer is:

SELECT * FROM information_schema.tables
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22761 Posts

Posted - 03/06/2014 :  06:39:05  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Another method

EXEC sp_tables

Madhivanan

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

DonAtWork
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 03/06/2014 :  07:08:18  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000