Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

sql server select query:
=================


I have memberTable have 150 columns, in this 150 columns 70 columns mandatory columns
remaining columns based on condition display columns,null value columns should not display.

example: I have 50 records in my memberTable. first 70 columns mandatory.In 71 to 150 not mandatory columns,
if table have data that columns only show it.remaining columns don't show it.

col1,col2,col3...col150
col1 to col70 must display
col71 to col150 which column have no value.don't show that columns.

How to write select query?.

What I have tried:

select * from memberTable;

it will display all columns.but in col71,col72,col73 ... col149,col150 some columns have null value.i don't show null value columns or empty columns.
Posted
Updated 23-Oct-18 5:51am

1 solution

This isn't a practical approach because there's a possibility that every record will have a different combination of null column values. When you do a query, *ALL* rows will have the same columns (that you specify in the SELECT statement).
 
Share this answer
 
v2
Comments
pkarthionline 24-Oct-18 4:10am    
select top 10 * membertable
where col71 is not null and col72 is not null and col73 is not null and col74 is not null and col75 is not null and
col76 is not null and col77 is not null and col78 is not null and col79 is not null and col80 is not null and
col81 is not null and col82 is not null and col83 is not null and col84 is not null and col85 is not null and
col86 is not null and col87 is not null and col88 is not null and col89 is not null and col90 is not null and
col91 is not null and col92 is not null and col93 is not null and col94 is not null and col95 is not null and
col96 is not null and col97 is not null and col98 is not null and col99 is not null and col100 is not null


but it display all columns.how to change query?
#realJSOP 24-Oct-18 6:05am    
It displays all columns because you said "select *". That means you return all columns.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900