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

[SQL] checking if a column exists in a table

Status
Not open for further replies.

Tsjipmanz

Programmer
Mar 28, 2001
1
NL
Hi!

I'm busy programming a Cold Fusion webpage and now I have to know whether there is a SQLmethod to check whether a column exisits in a table.
I know the stucture of the table myself, but for sortingparameters it might come out handy to check if it's indeed a column which can be sorted with.

TIA

Tsjipmanz

 
What's the backend? If it's Oracle then you could do

select 1
from user_tab_columns
where table_name = &Table_Name
and column_name = &Column_name;

Mike.
 
Just in case you have multiple instances of the same database, just with different owners, you can add to Mike's perfect solution like so:
Code:
select 1
from user_tab_columns
where table_name = &Table_Name
and column_name = &Column_name
and owner = &Owner_Name;

Good call Mike... Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top