Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

How to create a temporary table from resultset.

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
searchsanjaysharma
Asked:
searchsanjaysharma
2 Solutions
 
Surendra NathTechnology LeadCommented:
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
 
searchsanjaysharmaAuthor Commented:
Can you send any link.
0
 
Aaron ShiloChief Database ArchitectCommented:
hi

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

Pivot/Unpivot
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Anthony PerkinsCommented:
ashilo,

I suspect the keyword here was "dynamic"  :)
0
 
Anthony PerkinsCommented:
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
 
searchsanjaysharmaAuthor Commented:
tx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now