Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
FrankGrimm
Partner - Creator
Partner - Creator

select from SQL tables

Hello together,

i have to load SQl databases with the select order.

My problem is, that i dont know whether a column exits or not.

 

Example:

select

column1 as c1,

column2 as c2,

column3 as c3

from database.dbo.example;

 

Sometimes column3 exists in the table, sometimes not.

If column3 don´t exists, the dataload runs on an error.

How can i check, whether column3 exists, and if not how can i exclude column3 from the select order?

Thanks to all!

Frank

Labels (2)
2 Replies
Or
MVP
MVP

This isn't really a Qlik question, since it's specific to your SQL. But on the Qlik end, you could just Select * from your table and then rename using the Rename command, since Qlik won't crash if you try to rename a field that doesn't exist.

NadiaB
Support
Support

Hi @FrankGrimm 

If you are just reading all the columns available probably select * from table would work, but is you want to get specific files only maybe you will need to use sys tables to verify if the column exist, and generate a dynamic query. 

Hope it helps. 

Don't forget to mark as "Solution Accepted" the comment that resolves the question/issue. #ngm