Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
MaverickUK
Yak Posting Veteran
89 Posts |
Posted - 2004-07-02 : 11:33:42
|
Hi guysI've knocked up a quick questionnarie ASP database system.After an ASP form is submitted it loops through each form object name and value submitted in the ASP page and saves it to the database.So in the database I have a 3 column table holding the FormObjectName, FormObjectValue and FormID ( which is unqiue to each form submitted )So in the table, data looks likeFormName, FormValue, FormIDQ1, 123, 1Q2, ABC, 1Q1, asdas, 2Q2, 32432, 2etc...I want to run a procedure that'll return that data as this formatFormID, Q1, Q21, 123, asdas2, ABC, 32432etc...I'm guessing this is some type of pivot procedure? But even if it is, I've never done it because.Please could somebody share their experience in this area? Thanks  |
|
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2004-07-02 : 12:12:37
|
| select FormID, MAX(CASE WHEN FormName = 'Q1' THEN FormValue ELSE null END) 'Q1', MAX(CASE WHEN FormName = 'Q2' THEN FormValue ELSE null END) 'Q2'...from tableGROUP BY FormIDalso do a search here for Dynamic CrossTab because it may come in handy here. |
 |
|
|
MaverickUK
Yak Posting Veteran
89 Posts |
Posted - 2004-07-05 : 04:37:12
|
| Thx |
 |
|
|
|
|
|
|
|