Connect with Expertise | Find Experts, Get Answers, Share Insights

How to get table list from a db? Thanks!

rong.guo@gmail.com
 
Posts: n/a
#1: Aug 2 '05
Hi Group!

I would like to get a list of all the table names from a database, can
anybody please tell me how to do that? Many thanks!


Simon Hayes
 
Posts: n/a
#2: Aug 2 '05

re: How to get table list from a db? Thanks!


See sp_tables and sysobjects in Books Online.

Simon

Madhivanan
 
Posts: n/a
#3: Aug 2 '05

re: How to get table list from a db? Thanks!



Select table_name from information_schema.tables
where table_type='Base table' order by table_name

Madhivanan

Chandra
 
Posts: n/a
#4: Aug 4 '05

re: How to get table list from a db? Thanks!



Hi, you can write it as:

SELECT name [Table Name]
FROM sysobjects
WHERE xtype = 'U'

Please let me know if this helped

best Regards,
Chandra
http://www.SQLResource.com/
http://chanduas.blogspot.com/
---------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Madhivanan
 
Posts: n/a
#5: Aug 4 '05

re: How to get table list from a db? Thanks!


Chandra, It is better to use views and avoid using system tables

Madhivanan

Closed Thread