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
 Other SQL Server Topics (2005)
 field text

Author  Topic 

wided
Posting Yak Master

218 Posts

Posted - 2010-05-05 : 06:46:29

hello

i have 2 field text
table = table1
field1 = adress
field2 = country
i want to have the result like this

select adress+ ' '+country from table

if country is null then result is null when adress is not null

if the field is numeric, i use (isnull(fiels,0)) to have 0
what 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 canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-05-05 : 06:53:37
select adress+' '+coalesce(country,'') from table_name

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-05 : 07:39:59
select adress+ coalesce(' '+ country,'') from table_name

if you want to avoid extra traiiling space in case of no country value


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

Go to Top of Page

wided
Posting Yak Master

218 Posts

Posted - 2010-05-05 : 09:35:02
thanks is is ok
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-05 : 15:01:40
welcome

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

Go to Top of Page
   

- Advertisement -