Solved

SyBaseSQL Select column if it exists

Posted on 2014-04-06
3
1,355 Views
Last Modified: 2014-04-07
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
Comment
Question by:triphen
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
 

Author Comment

by:triphen
Comment Utility
I like the dynamic idea. How can I check if the column exists?
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now