Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 13-Feb-19 5:15am
v2
Comments
manub22 13-Feb-19 10:41am    
Can you provide from where you get these values, and what's the logic:
1 | 10 | 20 | 30 | 40 | 50
2 | 5 | 25 | 35 | 45 | 100
Nirmala Saravanan 13-Feb-19 10:52am    
that is simply I gave my own values for those columns
Nirmala Saravanan 13-Feb-19 10:58am    
1 | 10 | 20 | 30 | 40 | 50
2 | 5 | 25 | 35 | 45 | 100
the above are column values.

1 solution

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 ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900