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

Dynamic query where the same field is actually named slightly different with no rhyme or reason

Status
Not open for further replies.

wbodger

Programmer
Apr 23, 2007
769
US
I am working on some audit data, thought I was done and now they would like it further refined. No problem, I have that data, I will work it into the refinement. And now I find that with all of the databases and tables that I am stepping thru, the one field that they want me to refine on has three different names. It could be fid, formid or form_id and I have no idea which one it might be. So, is there any way (aside from running thru the information_schema for each db) to use multiple possibilities for a field to return? Only one of the three field names will exist, I just don't know which one it will be.
 
Isn't it the easiest solution to look it up and then know it?

Select * from INFORMATION_SCHEMA.COLUMNS Where COLUMN_NAME in ('fid', 'formid', 'form_id')

If you don't have access (remotely perhaps), the easiest of course would be to prepare 3 queries, execute them, catch their error and then log which one works, in the next software version then use the one working only.

Bye, Olaf.

 
Thanks, Olaf. I had forgotten I posted this, but I got it figured out last week using information_schema.columns.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top