Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
actually I am working in c# and sql2005
in query,am getting lot of null values. means there are some columns containing null values in each row.
i just want to ignore that column. means i want to show all columns containing values.

please advice
Thanks in Advance
Posted
Updated 25-Aug-11 21:05pm
v2
Comments
[no name] 26-Aug-11 4:48am    
Could you please elaborate more with an example ?

SQL
SELECT Col1, Col2, Col3 
FROM Table1
WHERE (Col1 IS NOT NULL)
AND (Col2 IS NOT NULL)
AND (Col3 IS NOT NULL)
 
Share this answer
 
Comments
RaisKazi 26-Aug-11 8:58am    
My 5.
Corporal Agarn 26-Aug-11 10:15am    
This will show only rows where all three columns have non null values. If you want rows that have one or two non null values use OR instead of AND.
you can try following LINQ query:

C#
var a = from p in obj.tableName where p.Col1 != null && p.Col2 != null select p;


If you are going through SQL query only then uper sollution is fine.

-Sagar Solanki
 
Share this answer
 
SELECT *
FROM Table1
WHERE Col1 IS NOT NULL
 
Share this answer
 
v2

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