Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT QUERY

Status
Not open for further replies.

Freemo

MIS
Oct 25, 2005
71
0
0
GB
Hi,

Is it possible to add fields into a SELECT query in SQL based on whether the field contains data?

For example I dont want to display the field 'telephonenumber' unless there is a telephone number set.

Thanks
 
It would be possible, but not very economical and could cause quite a lot more overhead than necessary. I'd say you'd be better off returning the full resultset and using whatever package you are using to display the data to hide the columns.

Mark,

Darlington Web Design[tab]|[tab]Experts, Information, Ideas & Knowledge[tab]|[tab]ASP.NET Tips & Tricks
 
you mean if every single row in your returned data has null for telephone number?

in that case, no, well, not easily anyway, you'd need to use dynamic queries and other select to check.

normally, I'd do something in the front end for this sort of thing...

--------------------
Procrastinate Now!
 
Thanks for the reply.

I need to extract the information in XML format and I am not sure how I can hide the field. I would like to automate it as much as possible.
 
Why don't you give an example of your xml input and desired output.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top