I am trying to create a stored procedure based on looking up information in system tables. I am pulling basic information such as Table name, records, field names, field types etc which is the source of data for an SSRS report. This is currently working fine. There is a request to add fields that will calculate totals for each field...for instance if there is a table with an Amount column, they would like to see the total of all the values in that table's column. What is the best way to get these totals for these fields without using a cursor?
I was thinking of selecting all of the numeric fields into a temp table, selecting the top 1 record from the temp table and getting the table and column name. Then running a sum on that column in the database based on dynamic SQL and updating the documentation table accordingly. Then deleting that record from the temp table after and reading the next top record, which would bypass the cursor.
Any other ideas?
Thanks
I was thinking of selecting all of the numeric fields into a temp table, selecting the top 1 record from the temp table and getting the table and column name. Then running a sum on that column in the database based on dynamic SQL and updating the documentation table accordingly. Then deleting that record from the temp table after and reading the next top record, which would bypass the cursor.
Any other ideas?
Thanks