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 gkittelson 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 in MS SQL

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?

Thanks in advance. Dmitriy
dbrom@crosswinds.net
 
go to SQL Server Enterprise manager (or the SQL snap-in to management console) and look into the systables and syscolumns tables. They have info on all the tables and the columns in each. You'll need to look at the table type (don't recall the exact column) to only select from user type tables.
 
Thanks...

I did what you suggested and looked at syscolumns table.
Strangely, I could not find the other one, systables table.
I found the columns from my tables in syscolumns, so at least I got some idea how to proceed.

tjanks again Dmitriy
dbrom@crosswinds.net
 
My memory isn't so great, so it could be that the systables table doesn't exist.

If not, then I guess you need to select all the columns that have the same tablename (if that's shown in the syscolumns table).

Sounds like you're on the right track though. Have fun!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top