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

Getting table and column names 1

Status
Not open for further replies.

dbrom

Programmer
Feb 21, 2001
100
US
Hi guys,

I am trying to develop an interface for the database so that a user with minimum knowledge would be able to write SQL queries from my ASP pages. I just want to do this for UPDATE, DELETE, INSERT, SELECT.
So I thought it would be very nice if I could first ask user to delect a table, then specific fields from a drop-down list. Do you know if it is possible - can I access table names and fiels names in MS SQL? I've gotten into syscolumns table and I saw my columns there, but how do I know whidh column belongs to which table. Also, I cannot find a system table with the table names.

Hope you can help me.
Thanks in advance. Dmitriy
dbrom@crosswinds.net
 
Hiya,

The system table that you need for the table names is called sysobjects. The easiest way to select only user tables (so does not list system tables) is to issue the command

SELECT name FROM sysobjects WHERE type = "U"

You can also use the id reference to join to the syscolumns table, which will produce the list of columns per table.

HTH

Tim
 
Thanks Tim!

That was exactly what I wanted to hear.
Now I know what to do.
Thanks again (-:,

Dmitriy Dmitriy
dbrom@crosswinds.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top