Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sql Null

Posted on 2011-09-06
3
Medium Priority
?
324 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 1000 total points
ID: 36486921
+ IsNull(location,'') +
0
 
LVL 15

Assisted Solution

by:gplana
gplana earned 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 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