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.
| Author |
Topic |
|
Mauricio Moreno
Starting Member
18 Posts |
Posted - 2007-08-20 : 18:31:50
|
| I would appreciate any help with my following problem... lets sayi have...select A.firstname + '' + B.lastname as fullname, 'Their Home is ' + A.City + ' ' + (select top 1 C.State from States C where C.City = A.City) as Location from tableA A, TableB BWhere A.id = b.idThis is not the actual statement but follows the same kinda logic... the problem that i get is that some of the rows in both my fullname column and in my location column show up as null... how would i fix it so for instance even if the state is missing it would still show: their home is LA or if just the last name is available it would show the lastname?Thank you |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-08-20 : 19:52:07
|
| Use ISNULL or COALESCE for each column.select COALESCE(A.firstname, '') + COALESCE(B.lastname , '')... etcDinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
Mauricio Moreno
Starting Member
18 Posts |
Posted - 2007-08-20 : 20:19:34
|
| Oh Thank you!!! |
 |
|
|
|
|
|