triphen
asked on
SyBaseSQL Select column if it exists
Hello Experts,
I am using SyBase SQL Anywhere v10. My databases I select from may vary from version to version on my application. How can I select a column only if it exists in the table, else return 'Nothing Found'. X, Y and Z exist for sure, but A column A may not exist.
Something like....
SELECT
x,
y,
z,
CASE WHEN IF EXISTS column A
ELSE 'nothing found'
FROM TABLE 1234567
I am using SyBase SQL Anywhere v10. My databases I select from may vary from version to version on my application. How can I select a column only if it exists in the table, else return 'Nothing Found'. X, Y and Z exist for sure, but A column A may not exist.
Something like....
SELECT
x,
y,
z,
CASE WHEN IF EXISTS column A
ELSE 'nothing found'
FROM TABLE 1234567
ASKER
I like the dynamic idea. How can I check if the column exists?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the only workaround I can suggest is to use views (or stored procedures), which would do the same ...
alternatively I only see dynamic sql: a query which checks if the column is there, and build the query as needed.