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 |
|
rudba
Constraint Violating Yak Guru
415 Posts |
Posted - 2009-02-27 : 16:29:45
|
| Hi,How do i add values from two columns. If col1 is not null but col2 is null.I tried this:Select ID, (CAST(col1 AS nvarchar(1000))+ CAST(col2 AS nvarchar(1000))) as Col3 FROM tbl1but i get the Col3 also null (Col1 has value but Col2 is null) |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-02-27 : 16:33:39
|
| use COALESCESelect ID, CAST(col1 AS nvarchar(1000))+ COALESCE(CAST(col2 AS nvarchar(1000)),'') as Col3 FROM tbl1 |
 |
|
|
rudba
Constraint Violating Yak Guru
415 Posts |
Posted - 2009-02-27 : 16:37:05
|
| Thanks vijayisonly |
 |
|
|
|
|
|