If a field doesn't exist I do not think you can get around it directly in a query.
You can use SQLs sp_columns procedure to get a list of columns or verify existance of a specific column in a given table and then build your query accordingly.
ie..
sqlexec(myconnectionhandle,[exec sp_columns 'mytable', @column_name = 'columninquestion'],'curs_columninfo')
if reccount('curs_columninfo')=0 && column wasn't found
mysqlcommand = [select column1,' ' as columninquestion from mytable]
else
mysqlcommand = [select column1,columninquestion from mytable]
endif
use in select('curs_columninfo')
sqlexec(myconnectionhandle,mysqlcommand,'curs_results')
>I am writing a routine which goes out and queries information from remote sites. 90% of the time, all the sites have the exact same database structure, but that other 10% for whatever reason, haven't received the latest update.
>
>I need to query a couple fields from a table, and I need to structure my statement so that a field doesn't exists, that I return a blank value for that rather than having the whole query fail. Is there a way to structure that in a query of stored procedure?
>
>Thanks
>
>Kirk
____________________________________
Don't Tread on Me
Overthrow the federal government NOW!
____________________________________