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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List tables only

Status
Not open for further replies.

babeo

Technical User
Mar 30, 2000
398
CA
Hi

Instead of using sp_tables to list all table names of a database including with other fields, I just want to list the table_name column only, or particular column. Is there a command or way to do that?

Thanks
 
hello,

try...

select name
from sysobjects
where type = 'U'
go

q.
 
If you want a specific column or columns, you can do this:

select table_name = object_name (id), name
from syscolumns
where name = 'the_column_name_you_want'

You can restrict that to a particular table or tables by adding a condition like this one:

and id = object_id ('the_table_in_question')

or, for several tables,

and id in (object_id ('table1'), object_id('table2'))

BOL,

John J M Craig
Alpha-G Consulting, LLC
nsjmcraig@netscape.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top