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 |
wided
Posting Yak Master
218 Posts |
Posted - 2010-05-05 : 06:46:29
|
helloi have 2 field texttable = table1field1 = adressfield2 = countryi want to have the result like thisselect adress+ ' '+country from tableif country is null then result is null when adress is not nullif the field is numeric, i use (isnull(fiels,0)) to have 0what a bout field text?tanks |
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-05-05 : 06:50:39
|
use coalesce()Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-05-05 : 06:53:37
|
select adress+' '+coalesce(country,'') from table_nameSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-05 : 07:39:59
|
select adress+ coalesce(' '+ country,'') from table_nameif you want to avoid extra traiiling space in case of no country value------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2010-05-05 : 09:35:02
|
thanks is is ok |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-05 : 15:01:40
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|