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 |
|
Astaroth
Starting Member
9 Posts |
Posted - 2007-11-13 : 17:49:56
|
| I am trying to improve my SQL and reduce the number of connections my website is making to the server.Currently I have a stored procedure that gets all the games (and their details) for a single user which works fine which uses a WHERE userid = @userid which is an Int value.I now need to create a new procedure which brings back the to all their "friends" (again by their userid). How is it best to do this? I originally tried to do a WHERE userID IN (@userid) but was unable to work out what variable type to use for @userid.Is it best to do a single query in this way or is there a way to use the existing SP, loop through the collection of userids and join the result together into a single set to return? If an IN is the best route, what is the correct datatype for the variable? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
Astaroth
Starting Member
9 Posts |
Posted - 2007-11-14 : 04:08:59
|
| PesoThanks for the suggestion but Mike has made a lot of posts and in the first 20 or so I have looked at there was nothing of relevance that I could see. Could you possibly narrow it down? Unfortunately searching for "in" inevitably doesnt work well. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-14 : 04:16:13
|
Then you should start by posting your table layout with proper and accurate sample data.Then you should write what the data represents and then write how the expected output should look like and why.Welcome back. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
Astaroth
Starting Member
9 Posts |
Posted - 2007-11-15 : 04:13:27
|
| I wasnt really sure of the relevancy of the over all structure of the db given there are 8 large tables with several interdependencies involved in the query but the question of "what param type to use for an 'in' for an int column type" isnt effected by the rest.I did however eventually find another site that suggested to create a CSV->table function and just inner join it to the query which works a treat |
 |
|
|
|
|
|