?
Solved

SyBaseSQL Select column if it exists

Posted on 2014-04-06
3
Medium Priority
?
1,592 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39982214
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
ID: 39983804
I like the dynamic idea. How can I check if the column exists?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 39984178
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month8 days, 16 hours left to enroll

764 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