Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie syntax help? identify table names

Status
Not open for further replies.

TWillard

Programmer
Joined
Apr 26, 2001
Messages
263
Location
US
I am trying to identify all of the table names through sql using Server Query Anaylizer. If I was using Oracle, I would write the following at the sql prompt.

select table_name from user_tables;
or
select table_name from all_tables;

What is the syntax for this in sql server? I know that I could use Server Enterprise Manager, to ackomplish this task. However, my connection with Enterprise Manager is slow. I also feel that it is tedious to switch between windows when performing sql commands. Thank You for reading my posts.

Tim
 
SELECT name FROM <dbname>..sysobjects where OBJECTPROPERTY(id,'IsUserTable')=1

OR you can run

SELECT name FROM <dbname>..sysobjects where where type = 'U'
 

The recommended method is to use the Information Schema views or the system stored procedure sp_help.

Select Table_Name From Information_Schema.tables
Where TABLE_TYPE='BASE TABLE'

exec sp_help

However, sp_help lists views as well as tables. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top