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
 SQL Server Development (2000)
 Building Temp Table from loop

Author  Topic 

Vivaldi
Constraint Violating Yak Guru

298 Posts

Posted - 2001-05-02 : 10:40:58
Well,

Back again with more confusion.

I have a "lookup" table of counties
ID | Countyname

I want to loop through all the counties in the table
inside a stored proc and
in that loop

get an average from another temp table that is based on that average, but i have 4 specific averages i need to retrieve in order for each county.

so in pseudo
for each county
get avg for male felonies for county
get avg for male misdeamenors for county
get avg for female felonies for county
.....
next

so that table has
county1 | avg1 | avg2 | avg3 | avg4
county2 | avg1 | avg2 | avg3 | avg4
county3 | avg1 | avg2 | avg3 | avg4
county4 | avg1 | avg2 | avg3 | avg4


and i can return that for formatting to my asp page.

I know how to do this using asp but if there were 100 + counties thats alot of db calls to be making.

Any leads? i have a feeling a cursor is in order, if you could just point me in a direction that will lead to a euphoric state, I would be most pleased.

Software Composer
   

- Advertisement -