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
 General SQL Server Forums
 New to SQL Server Programming
 Using the following conver NULL to "BLANK"

Author  Topic 

rnelsch
Starting Member

31 Posts

Posted - 2012-10-25 : 17:22:47
I have the following in a query. How would I convert NULL(or blank) values in the Project.LeadSource column to show up as "BLANK" or "12345" for example? COALESCE is what I was thinking but not sure where to put it or format it?

Select Project.LeadSource,
Project.Department,
Invoice.TotalAmount,
Job.JobID
From Project
Right Join Invoice On Project.ProjectID = Invoice.ProjectID
Full Join PhoneCall On Project.JobType = PhoneCall.JobType And
Invoice.JobID = PhoneCall.ForJobID
Full Join Location On Invoice.LocationID = Location.LocationID
Right Join Job On Invoice.JobID = Job.JobID
Where Invoice.PostDate Between '@Request.islSelectBeginningDate~' And
'@Request.islSelectEndingDate~'

Ryan A Nelsch

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-25 : 17:27:14
replace Project.LeadSource with

COALESCE(NULLIF(Project.LeadSource,''),'BLANK')

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -