SQLTeam.com | Weblogs | Forums

Bulk Calulation of Data


#1

I have data in a SqlServer table and I have an asp.net front-end. I am selecting the data into a form in asp.net and I am clicking a button to perform a calculation on the data. There are maybe 300 records and I want the same calculation performed on each record I have selected. The calulation will take the form of adding the value in two fields in the record and then multiplying that amount by 1.23.

Anyone any ideas on best way to do this?


#2

why not just do it in the front end?


#3

For performance reasons I would prefer to do the calculation in the DB.
I would have to do the same calculation on each record that has been selected so the Stored Procedure would have to get all the ID's from the selected data passed to it and then perform the calculation on each record one by one and then write the result to a field in each record corresponding to that record.

Anyone know how to do this?


#4

Are you trying for

SELECT (Field1 + Field2) * 1.23 AS OutField FROM mytable;

#5

Yes but I only want it done on the records I have selected in the asp.net gridview... I would have maybe 300 records and I would be passing in their ID's and only these records the calculation would be carried out on .... Thats what I'm trying to achieve.


#6

In that case, for performance reasons, do the calculations in the front end.


#7

So the recommendation is to do the calculations in teh Asp.net Gridview?


#8

yes, certainly