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 |
|
acdacd
Yak Posting Veteran
63 Posts |
Posted - 2005-07-03 : 09:24:39
|
| Dear all,I would like to write a stored procedure.I suppose to do sth like this Declare abc_cursor Cursor For (Select abc = @abc from bcd table)However, it is not allowed.The reason that i choose cursor is that this table will return more then one value, therefore, i cannot use the typical variable. Since there are no array in sql. Can anyone give me some help?Thxacdacdbe a hardworking people!! |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-07-03 : 12:59:38
|
| A cursor won't allow you to return more than one row at a time anyway.Can you post all of your existing code, and/or a description of exactly what you're trying to do? In all likelihood you won't need a cursor anyway. |
 |
|
|
acdacd
Yak Posting Veteran
63 Posts |
Posted - 2005-07-03 : 13:13:12
|
| My ReqTwo tables: Person, interestMy system have matching function for people share same or similar interest. Also , each people can many interests.In the user-defined function, i would to deal problem of matching people. Since, the single variable can only get the one scalar value, my orginal idea is to use the cursor(like loop in prog lang) to get each one and match. i.e. For any person, get all his interests.Is there any way to do it?Also, are doing matching in DB a good idea?Since i only supposed to counter the same interest and give each of them a mark.Thxbe a hardworking people!! |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2005-07-03 : 15:33:10
|
| In general, this seems to be a "many-to-many" relationship. One person can have many interests and one interest can be shared by many people. A common approach to implementing this is to use a "junction table" in addition to the two tables you already have (People and Interests). The columns of the junction table could be as simple the two primary keys from People and Interests.Look up junction table in BOL or any database book for further details.HTH================================================================='Tis with our judgements as our watches: none Go just alike, yet each believes his own. -Alexander Pope, poet (1688-1744) |
 |
|
|
acdacd
Yak Posting Veteran
63 Posts |
Posted - 2005-07-04 : 00:45:46
|
| Thx.In my situation, the junction table is only used by this stored proc, should i create temp table/view or sth like this ?be a hardworking people!! |
 |
|
|
|
|
|
|
|