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 |
sureshprpt
Starting Member
33 Posts |
Posted - 2014-06-24 : 01:04:39
|
Hi All,I need one sql query to merge two columns , at the time of merging i need to insert "." between the two columns.if my second column is blank , the "." not needed in the output. The example mentioned below for your ready referceCol1 Col2 - Otuput Needed1100 IICI 1100.IICI1100 IBSI 1100.IBSI1200 12001300 13001400 SCIB 1400.SCIBThanks |
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2014-06-24 : 02:35:03
|
but the second column has values for all the rows,you want to concatenate only if there are character values in col2?Javeed Ahmed |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2014-06-24 : 02:36:32
|
can you try this oneselect case when col2!=null then col1+'.'+col2 else '' end as col3 from table1Javeed Ahmed |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2014-06-24 : 04:17:13
|
SELECT Col1, Col2, LTRIM(ISNULL(Col1, '') + ISNULL(' ' + Col2, '')) Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
|
|
|
|
|