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
 Null Blanking Combined Query

Author  Topic 

mflammia
Starting Member

44 Posts

Posted - 2008-10-08 : 18:30:58
Using the Sql query below works fine for what I need, until one of the columns has a NULL in it. Then the whole result is returned as NULL instead of just stepping over it, why is that and any ideas how I fix it?

Select (__DETAILS + CHAR(13)+ CHAR(13) + _PRICE + CHAR(13) + CHAR(13) +_TIMES +CHAR(13) + CHAR(13) +_CONTACT + CHAR(13)+ CHAR(13) + _DIRECTIONS) from realessex.dbo._DATA

Many Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-10-08 : 18:33:17
You can fix this with COALESCE function, ISNULL function, CASE statement, or CONCAT_NULL_YIELDS_NULL option.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mflammia
Starting Member

44 Posts

Posted - 2008-10-08 : 19:14:28
Thanks very much for the help.

For the record I used the ISNULL function below and it fixed my problem:

Select (__DETAILS + CHAR(13)+ CHAR(13) + isnull(_PRICE,'') + CHAR(13) + CHAR(13) +_TIMES +CHAR(13) + CHAR(13) +_CONTACT + CHAR(13)+ CHAR(13) + _DIRECTIONS) from realessex.dbo._DATA
Go to Top of Page
   

- Advertisement -