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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 How to get all the table names by query

Author  Topic 

markshen2006
Starting Member

15 Posts

Posted - 2008-04-05 : 00:58:10
Hi,

I have a database that have two handred tables.I want to get all the table name list.

Would you please help me if you know how to do this (query or build-in stored procedure).

Thanks

Mark

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-04-05 : 01:00:08
sp_tables
or
select name from sysobjects
where type='U'
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2008-04-05 : 01:06:21
In SQL Server 2005 you should use sys.objects rather than sysobjects (sorry being picky). Also, consider the information schema view INFORMATION_SCHEMA.TABLES.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-04-05 : 01:10:46
who said that? Try it and see.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-05 : 02:17:40
quote:
Originally posted by sodeep

who said that? Try it and see.


For backward support, SQL Server 2005 supports sysobjects as well. But sys.objects has more columns

Also why are you using different font style for your postings as forum's default is more readable

Madhivanan

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

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-04-05 : 03:20:26
Sysobjects has been retained for backward compatibility

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-04-05 : 22:39:48
Have to call it sys.sysobjects.
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2008-04-05 : 23:06:25
quote:
Originally posted by sodeep

who said that? Try it and see.


I didn't say you must use sys.objects, I said you should use sys.objects, and who said that - SQL Server Books Online, see the topic on sysobjects, it says
quote:
This SQL Server 2000 system table is included as a view for backward compatibility. We recommend that you use the current SQL Server system views instead.

Go to Top of Page
   

- Advertisement -