SQL Server将两个字段数据合并成一个字段显示(字段与字段添加特殊符号)减号 中括号 小括号

--用中括号实现两个字段组合成一个并显示
select Phone  as 手机号,
 (CAST(Name  as varchar(20))+'['+ CAST (ShopNo as varchar(20))+']')
  as 姓名工号
 From Shopping (NOLOCK) t order by CreateDate desc
 --用括号实现两个字段组合成一个并显示
 select Phone  as 手机号,
 (CAST(Name  as varchar(20))+'('+ CAST (ShopNo as varchar(20))+')')
  as 姓名工号
 From Shopping (NOLOCK) t order by CreateDate desc

 --用减号实现两个字段组合成一个并显示
 select Phone  as 手机号,
 (CAST(Name  as varchar(20))+'-'+ CAST (ShopNo as varchar(20)))
  as 姓名工号
 From Shopping (NOLOCK) t order by CreateDate desc

 

posted @ 2020-07-15 10:56  蜜雪粮液  阅读(1265)  评论(0编辑  收藏  举报