hi,
This is my query. I need to display the data which is not null. I don't want to display null values. in my database there is only one record with exact city name but it display city which contain null values also.
declare
@NAME varchar(2000),
@CITY varchar(250),
@Country varchar(250)
SELECT customer_id,
(coalesce(city, '') + coalesce(', ' + state, '')) as Location ,
(coalesce(address1, '') + coalesce(', ' + address2, '') + coalesce(', ' + address3, '')) as Address
FROM customer LEFT outer JOIN usercountry on usercountry.country_ab = customer.country
left outer JOIN customerstatus on customerstatus.statusId = customer.statusid
Where
1=1
AND (city like '%' + ISNULL(@CITY,city) + '%' or city is null)
AND user_country.country like '%' + ISNULL(@Country,usercountry.country) + '%'
AND customerstatus.status = 'pending'
Thank you,

Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Nov 25, 2014, 6:11 PM EST
use ISNULL with city it will remove null .
Ramesh MaruthiRank #937 · 2.2K reputationPosted Nov 25, 2014, 8:57 AM EST
Jitendra KumarRank #760 · 3K reputationPosted Nov 25, 2014, 7:13 PM EST
City<>''
City is not null