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 |
|
gongxia649
So Suave
344 Posts |
Posted - 2006-09-20 : 13:48:08
|
| ad1 ad2-----------------------------younge joenull nullyoun nullwant a result like that. anyone can help me to do it?ad1+ad2 -----------------------younge joenullyoun |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
gongxia649
So Suave
344 Posts |
Posted - 2006-09-20 : 13:57:12
|
| i want to write a code to concatenate 2 fields. But when the fields are null. It should also display null |
 |
|
|
Gopi Nath Muluka
Starting Member
22 Posts |
Posted - 2006-09-20 : 13:58:33
|
| try thisselect nullif(isnull(ad1,'')+isnull(ad2,''),'') as full1 from t1Thanks,Gopi Nath Muluka |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-09-20 : 14:43:07
|
quote: declare @table table(f1 varchar(20) null,f2 varchar(20) null,result varchar(20)null )insert @table (f1,f2)select null, null union allselect null, 'amber' union allselect 'yui', 'kanth' union allselect 'donnal', null select * from @tableupdate @table set result = f1 + f2select * from @table
Thanks for the prep work :)set result = coalesce(f1 + ' ' + f2, f1, f2)Be One with the OptimizerTG |
 |
|
|
gongxia649
So Suave
344 Posts |
Posted - 2006-09-20 : 14:45:12
|
| Gopi Nath Muluka, thanks it worksTG, it works too |
 |
|
|
|
|
|
|
|