Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
i need to Populate agg_besn column by concatenating agg and besn columncondition is : when agg is blank then '_' should not comeelse it should concatenate with '_'case statement should no usedTried so far:
Select agg,besn,IsNull ( agg,'') + '_' + besn as agg_besn From Portactual out should be:agg besn agg_besn1.2 Prch 1.2_prch Root Root
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts
Posted - 2010-04-21 : 14:54:40
One way..
Select agg,besn,case when agg = '' then besn else agg + '_' + besn end as agg_besn From Port
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2010-04-21 : 23:22:00
Select agg,besn,COALESCE(NullIF( agg,'') + '_','') + COALESCE(besn,'') as agg_besn From Port------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/