我想把两列合并 变成 100:ff 101:ff 102:gg SQL code: --> 测试数据: #tb if object_id('tempdb.dbo.#tb') is not null drop table #tb go create table #tb (A int,B varchar(2)) insert into #tb select 100,'ff' union all select 101,'dd' union all select 102,'gg'
select cast(A as varchar(10))+':'+B from #tb
------------- 100:ff 101:dd 102:gg
(3 行受影响)
select ltrim(a) + ':' + b from tb
select cast(a as varchar) + ':' + b from tb
SQL code:
select rtrim(ltrim(A))+':'+rtrim(ltrim(B)) from tt