Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to Ignore NULL records....

Author  Topic 

vision.v1
Yak Posting Veteran

72 Posts

Posted - 2009-07-31 : 09:07:31
Hi,

I have a table #temp1 with two cols

TableName : #temp1

name city
---- ----
aaa cone
bbb ctwo
NULL NULL
NULL NULL
ccc cthree

when i select table like
select * from #temp1 it will display all records

name city
---- ----
aaa cone
bbb ctwo
NULL NULL
NULL NULL
ccc cthree

but my requirement is when i select the table it should ignore the records for which all the columns are NULL

result should be:

name city
---- ----
aaa cone
bbb ctwo
ccc cthree

please give replys...



khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-31 : 09:14:50
select * from #temp1 where name is not null and city is not null


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2009-07-31 : 09:25:46
Another way

select * from #temp1 where Coalesce(city,name)is null

PBUH
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-31 : 09:37:42
select * from #temp1 where Coalesce(city,name,'') <> ''
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2009-07-31 : 09:44:27
oops sorry I made a mistake in my previous post

select * from #temp1 where Coalesce(city,name)is not null


PBUH
Go to Top of Page
   

- Advertisement -