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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Help with cursor please

Author  Topic 

cedartie
Starting Member

6 Posts

Posted - 2005-02-22 : 09:23:56
Hello,

I have a table in which profile information is stored. I need to display the data on a question to answer basis, even if there is more than one answer I need to show it as one, for instance if a person was asked what price range they are interested in they can chose more than one.

Currently in the table it will look like this

UserID Question Answer
Y1TH2 4 Under $200,000
Y1TH2 4 $200-250,000
Y1TH2 4 $250-300,000
XZ23K 4 Under $200,000
XZ23K 4 $200-250,000

I need to display it as

UserID Question Answer
Y1TH2 4 Under $200,000, $200-250,000, $250-300,000
XZ23K 4 Under $200,000, $200-250,000

I have been told this can be done in a cursor but I'm pretty new to cursors. Any help would be greatly appreciated!

X002548
Not Just a Number

15586 Posts

Posted - 2005-02-22 : 10:03:36
Have a look

http://weblogs.sqlteam.com/brettk/archive/2005/02/10/4153.aspx



Brett

8-)
Go to Top of Page

cedartie
Starting Member

6 Posts

Posted - 2005-02-22 : 10:06:37
For some reson that link won't come up for me 8-(
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-02-22 : 10:16:46
A UDF is the most efficient way to do it (see the 2nd post):

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=19647

- Jeff
Go to Top of Page
   

- Advertisement -