This is my first time doing this... For my assignment, I need to combine multiple stored procedures into one big report using a cursor. There is only one table Debt from the database college. Here is a link to the data dictionary: Data Dictionary
Currently, this is one of the 4 stored procedures that I have to output at 10%, 25%, 75%, and 90%. I'm trying to combine 10%, 25%, 75%, and 90% into one report when I execute the combined stored procedure. Also, when searching for a string in the combined stored procedure it will return any similar values. For example, the string 'ala' returns any strings in the format specified and in this case, it would probably return all colleges relating to Alamaba.
USE [college] GO /****** Object: StoredProcedure [dbo].[sp_10Report] Script Date: 2/23/2019 1:41:44 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[sp_10Report] ( @UNITID float ) AS BEGIN DECLARE @INSTNM VARCHAR(200) DECLARE @Query NVARCHAR(500) DECLARE @CUML_DEBT_P10 float DECLARE @CUML_DEBT_N float DECLARE @AVG10 float DECLARE @AVGN float DECLARE @SUMN float DECLARE @WAVG float SET @AVG10 = (select AVG(CUML_DEBT_P10) from Debt) SET @AVGN = (select AVG(CUML_DEBT_N) from Debt) SET @WAVG = (select SUM(CUML_DEBT_P10*CUML_DEBT_N)/SUM(CUML_DEBT_N) from Debt) select 'Cumulative debt at 10%' as Satistic, CUML_DEBT_P10 as 'Institution Value', @AVG10 as 'Average Value', @WAVG as 'Weighted Average' from Debt where UNITID = @UNITID END GO