Solved

Sql Null

Posted on 2011-09-06
3
318 Views
Last Modified: 2012-05-12
Hey guys, i have a question.

i have an sql query

select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + location + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng FROM dbo.pretoria where active='Yes'


my problem is here

'<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + location + '<br> Contact: ' + tel  as InfoWindowText

if my location is null it not pulling

so how can i have an if statement in that query so if loction is null it must not add the location and if it is not null add the loction to the nfoWindowText?

0
Comment
Question by:JCWEBHOST
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
John_Arifin earned 250 total points
ID: 36486921
+ IsNull(location,'') +
0
 
LVL 15

Assisted Solution

by:gplana
gplana earned 250 total points
ID: 36487107
'<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + isNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText
0
 
LVL 4

Expert Comment

by:AnuTiji
ID: 36487411
Hi
You can use ISNULL() function to check whether the location field is null or not. SQL query is pasted below:
select 
		DISTINCT UPPER(r_name) as r_name, 
		UPPER(address) as address, 
		area, 
		location, 
		p_code, 
		tel, 
		website, 
		'<b>'+ r_name + '</b>' + '<br>' + [address] + '<br>' + area + '<br>' + ISNULL(location,'') + '<br> Contact: ' + tel as InfoWindowText,
		Latitude as Lat, 
		Longitude as Lng
	FROM dbo.pretoria 
		 where active='Yes'

Open in new window


0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question