Solved

How to create a temporary table from resultset.

Posted on 2013-12-28
6
223 Views
Last Modified: 2014-01-20
When i run this query i get the following resultset

SELECT distinct SubjectCode from  IND13I.DBO.MSTMASSSTUDENTS
WHERE Course='B.Arch' and semester=1 order by 1

Resultset
SubjectCode
AR101
AR102
AR103
AR104
AR105
AR106
AR107

How to display this in horizontal or as columns  or how to transpose it so that i can create the table as
create table x (AR101 VARCHAR(200),AR102 VARCHAR(200) and so on

Is it possible.
0
Comment
Question by:searchsanjaysharma
6 Comments
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39744136
Yes, it is possible what you are looking for is called dynamic pivot functioanlity there are many examples out there in the web, I suggest you to look into one
0
 

Author Comment

by:searchsanjaysharma
ID: 39745519
Can you send any link.
0
 
LVL 15

Assisted Solution

by:Aaron Shilo
Aaron Shilo earned 250 total points
ID: 39746837
hi

this is a great example for using pivot to solve your problem

Pivot/Unpivot
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39746903
ashilo,

I suspect the keyword here was "dynamic"  :)
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
ID: 39746930
searchsanjaysharma,

Can you send any link.
See if this link helps:
http://bit.ly/1cigO7I

Blind links are no longer supported on EE, so you may want to hurry up and click on it before EE removes it.
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 39794094
tx
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question