Solved

How to create a temporary table from resultset.

Posted on 2013-12-28
6
216 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now