594
社区成员
发帖
与我相关
我的任务
分享
-- 这个意思 ?
create table test(
id int,
name varchar(10),
age int,
address varchar(10),
other varchar(10)
)
go
insert into test values
(1, '李明', 10, '上海',''),
(2, '小王', 0, '北京', '博士'),
(3, '小周', 21, '', '学士')
go
with m as (select * from test)
select 1 xh, id pk,'id' id , 'name', 'age', 'address', 'other' from m
union all
select 2, id pk, ltrim(id), name, ltrim(age), address, other from m
order by pk ,1
go
drop table test
go
1 1 id name age address other
2 1 1 李明 10 上海
1 2 id name age address other
2 2 2 小王 0 北京 博士
1 3 id name age address other
2 3 3 小周 21 学士
(6 行受影响)