?
Solved

How to create a temporary table from resultset.

Posted on 2013-12-28
6
Medium Priority
?
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1000 total points
ID: 39746837
hi

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

Pivot/Unpivot
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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 1000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

762 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