• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1710
  • Last Modified:

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
0
triphen
Asked:
triphen
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this does not exist in any dbms I know of ...

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.
0
 
triphenAuthor Commented:
I like the dynamic idea. How can I check if the column exists?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now