Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create columns based on anothers tables rows?

Status
Not open for further replies.

lemkepf

Technical User
Oct 8, 2002
86
0
0
US
Hello all! I need to create a stored procedure that will create columns in one table, based on rows in a different table.
I dont even know where to begin!! (i know how to do a stored procedure, but i'm stumped on actualy working through it to get my desired output.)
Any help is appreciated! Thanks again!
Paul
 
The whole idea seems wrong.

Could you elaborate on why and give some example of what you are trying to accomplish.
 
Are we talking about copying elements within a row of a source table and importing that information/data into a target table OR are you trying to create field names in the target table based on data in the source table?

Thanks

J. Kusch
 
Well to answer your question swampBoogie:
Basically, we have a DB table that holds 2 columns. Name and Rename (we basically use it to change the name of some fields in some of our Apps to readable names)

We are developing an app that displays rows of data in a ASP page with the renamed field being in there. What i want to do, is give the user the opportunity to pick and choose what fields they want to see. So the best way i could think of it was to take the renamed name, turn it into a column.
i have one column called username, then the rest of the renamed fields as columns, then the user can put in a different name in that column.

Is there a better way to do this?
Thanks a ton!
Paul
 
OH yea, and the reason i want it a stored procedure, is so whenever i add a new row, i can check and add a new column in my other table that has the users special renamed fields. Thanks!
 
I would return the list of the headers to the application and do the translation there.

What would happen in your alter table scenario if the procedure was called by multiple users simultaneously?
 
OK, well that's not the way i would like to do it, i guess it's really the only way (unless i wanted to do some really funky statements).
I wouldn't have to alter the table unless something had changed inthe other one, so i don't think it should be a problem if many users access it (besides, i'll lock the DB when i do call it).

Thanks a ton guys! If anyone else has any ideas, feel free to post them!
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top