|
 |
asp_databases thread: RE: Dynamic column names for a temp table from fields from another
Message #1 by "Roy, Siddarth S" <sroy@b...> on Wed, 10 Jul 2002 12:13:58 -0400
|
|
if u go by the rule of creating views They are also created by
selecting the data from two or three tables
create view (select t1.empno ,t1.ename,t2.ssno,t2.area from this table
t1,table t2 where =3Dcondition )
syntax may be wrong .Please check
I hope this also should work for the creation of the table
I dont have an idea of the updates in the table
Hope This Helps
thx
sid
-----Original Message-----
From: Azinger, Richard [mailto:richard.azinger@p...]
Sent: Wednesday, July 10, 2002 11:58 AM
To: ASP Databases
Subject: [asp_databases] Dynamic column names for a temp table from
fields from another
Is there a way for SQL to make a temp table from parts of another table.
My "answer" table is made up of columns:
sslID - unique individual
sessionID - class/session that the individual is signing up for
columnName - question to be used as a column name
answer - anwswer to the question
This is what the "answer" table looks like with data.
sslID sessionID columnName answer
------ --------- ---------- ------
1 1 firstName Richard
1 1 lastName Azinger
1 1 email
Richard.Azinger@p...
1 1 building 38
1 1 ext 2272
1 1 walkGroup no
1 1 goalFit500 Increased
energy level
2 1 firstName Michelle
2 1 lastName Azinger
2 1 email
mazinger@?????.com
2 1 workPhone ???-????
2 1 homeAddress some address
2 1 homePhone ???-????
2 1 walkGroup no
2 1 goalFit500 Increased
energy level
A sample query that I'd like to run would be:
SELECT sslID, firstName, lastName, goalFit500 FROM tempTable WHERE
sessionID =3D 1
To do this I think I would need to make a temporary table that made
column
names from the "answer.columnName" field.
The reason I'm setting up the answer table this way is because the
addministrator of the programs/classes the people will be signing up for
will have different questions for every new program/class she comes up
with.
I don't want to go to the SQL admin everytime she want to add a new
column.
I know that I can just iterate through the data in ASP to get what I'm
looking for but I thought there would be an easier way.
Thanks for your time,
Rich Azinger
Message #2 by "Azinger, Richard" <richard.azinger@p...> on Wed, 10 Jul 2002 10:57:49 -0500
|
|
Is there a way for SQL to make a temp table from parts of another table.
My "answer" table is made up of columns:
sslID - unique individual
sessionID - class/session that the individual is signing up for
columnName - question to be used as a column name
answer - anwswer to the question
This is what the "answer" table looks like with data.
sslID sessionID columnName answer
------ --------- ---------- ------
1 1 firstName Richard
1 1 lastName Azinger
1 1 email
Richard.Azinger@p...
1 1 building 38
1 1 ext 2272
1 1 walkGroup no
1 1 goalFit500 Increased
energy level
2 1 firstName Michelle
2 1 lastName Azinger
2 1 email
mazinger@?????.com
2 1 workPhone ???-????
2 1 homeAddress some address
2 1 homePhone ???-????
2 1 walkGroup no
2 1 goalFit500 Increased
energy level
A sample query that I'd like to run would be:
SELECT sslID, firstName, lastName, goalFit500 FROM tempTable WHERE
sessionID = 1
To do this I think I would need to make a temporary table that made column
names from the "answer.columnName" field.
The reason I'm setting up the answer table this way is because the
addministrator of the programs/classes the people will be signing up for
will have different questions for every new program/class she comes up with.
I don't want to go to the SQL admin everytime she want to add a new column.
I know that I can just iterate through the data in ASP to get what I'm
looking for but I thought there would be an easier way.
Thanks for your time,
Rich Azinger
|
|
 |