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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 not to return null

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-03-08 : 04:33:16
i have

select @mystring='xxx'+ '&work_phone_ext=' + cast(work_phone_ext as varchar) from customers where id=45

now if work_phone_ext is null then it makes the whole mystring null -- how can i make it just return a blank if it is null?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-08 : 04:41:06
select @mystring = 'xxx' + '&work_phone_ext=' + isnull(cast(work_phone_ext as varchar), '')
from customers
where id=45


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2007-03-08 : 15:33:54
select @mystring=coalesce('xxx'+ '&work_phone_ext=' + cast(work_phone_ext as varchar),'') from customers where id=45



--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -