非固定数量列显示
时间:2011-11-25
来源:互联网
列名编号 名称
1 a
2 b
3 c
4 d
5 e
表2
编号 1 2 3 4 5
001 r r d s s
002 d d f f v
通过这两个表想要的效果:
编号 a b c d e
001 r r d s s
002 d d f f v
......
其中表1的列名编号和表2的1,2,3,4,5是名称相同。相当于把表2的1,2,3,4,5猎头 替换成 表1的名称
作者: wangquan77731 发布时间: 2011-11-25
--> --> (Roy)生成測試數據 if not object_id('表1') is null drop table 表1 Go Create table 表1([列名编号] int,[名称] nvarchar(1)) Insert 表1 select 1,N'a' union all select 2,N'b' union all select 3,N'c' union all select 4,N'd' union all select 5,N'e' Go --> --> (Roy)生成測試數據 if not object_id('表2') is null drop table 表2 Go Create table 表2([编号] nvarchar(3),[1] nvarchar(1),[2] nvarchar(1),[3] nvarchar(1),[4] nvarchar(1),[5] nvarchar(1)) Insert 表2 select N'001',N'r',N'r',N'd',N's',N's' union all select N'002',N'd',N'd',N'f',N'f',N'v' Go declare @s nvarchar(1000) set @s='select [编号] ' Select @s=@s+',' +quotename([列名编号])+' as '+quotename([名称])from 表1 print @s exec(@s+' from 表2') /* 编号 a b c d e 001 r r d s s 002 d d f f v */
作者: roy_88 发布时间: 2011-11-25
作者: wangquan77731 发布时间: 2011-11-25
SQL code
--> --> (Roy)生成測試數據
if not object_id('表1') is null
drop table 表1
Go
Create table 表1([列名编号] int,[名称] nvarchar(1))
Insert 表1
select 1,N'a' union all
select 2,N'b' union all
sele……

作者: fredrickhu 发布时间: 2011-11-25
谢谢,请问这些代码能ACCESS中 编译通过吗?
昏迷 不能。
作者: fredrickhu 发布时间: 2011-11-25
作者: qianjin036a 发布时间: 2011-11-25
谢谢,请问这些代码能ACCESS中 编译通过吗?
作者: szstephenzhou 发布时间: 2011-11-25
作者: pengxuan 发布时间: 2011-11-25
作者: HJ_daxian 发布时间: 2011-11-25
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28