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
 select as null query

Author  Topic 

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2011-01-26 : 09:54:54
Hi friends

I trust you are all well

Once I again I have an issue, here's the code:

(P.Product_Title + ' - ' + O.Option_Title) As Product_Title,

now if O.Option_Title is null the Product_title is returned as null even though P.Product_Title has data in it. How do I work around this?

Many thanks in advance

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-01-26 : 10:10:54
(P.Product_Title + ' - ' + ISNULL(O.Option_Title, '')) As Product_Title,
Go to Top of Page

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2011-01-26 : 10:14:05
Absolutely beautiful Russell
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-26 : 11:09:30
if you want to avoid unwanted - also at the end make it

(P.Product_Title + ISNULL(' - ' + O.Option_Title, '')) As Product_Title,

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

Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-01-26 : 15:27:06
quote:
Originally posted by visakh16

if you want to avoid unwanted - also at the end make it

(P.Product_Title + ISNULL(' - ' + O.Option_Title, '')) As Product_Title,

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





Good catch.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-27 : 12:10:13
tnx

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

Go to Top of Page
   

- Advertisement -