如何将一个表的列值作为列名获取到另一个表 [英] How to get a column values of one table as column name to another table
问题描述
大家好,
在Sql Server中
我有表1
T1 T2
--------
1 HO
2孟买
3 Chennai
4班加罗尔
5德里
我必须创建另一个表格2表格动态
A1 |何|孟买|钦奈|班加罗尔|德里
----------------------------------------- -----
1 | 10 | 20 | 30 | 40 | 50
2 | 5 | 25 | 35 | 45 | 100
请帮助。
提前致谢
问候
Nirmala
我尝试过:
我试过搜索。我找不到合适的答案
Hi All,
In Sql Server
I have Table 1
T1 T2
--------
1 HO
2 Mumbai
3 Chennai
4 Bangalore
5 Delhi
I have to create another table Table 2 dynamically
A1 | HO |Mumbai | Chennai | Bangalore | Delhi
----------------------------------------------
1 | 10 | 20 | 30 | 40 | 50
2 | 5 | 25 | 35 | 45 | 100
Pls help.
Thanks in advance
Regards
Nirmala
What I have tried:
I tried searching. I could not find a proper answer
推荐答案
您可以在SQL Server Management Studio中以交互方式执行此操作。从一个表生成创建脚本(在数据库|表格|任务下),更改名称等。
或从xxx中选择(*)。
这取决于:你想要一个永久表,临时表,本地表,还是?
You can do this interactively in SQL Server Management Studio. Generate a "create" script (under Database | Table | Tasks) from the one table, change the name, etc.
Or select(*) from xxx.
It depends: you want a permanent table, temporary table, local table, or ?
这篇关于如何将一个表的列值作为列名获取到另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!