Solved

Sql Null

Posted on 2011-09-06
3
314 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now