Last post Sep 11, 2019 05:19 AM by Yang Shen
Sep 10, 2019 03:50 PM|zhao790|LINK
I have a SQL stored procedure to filter our company's employee overtime data such as employeeID, GroupID, dateOverTime,, OverTimeHours, OvetTimeDollar, OvertimeReasonID implemented by third party.
Now I am required to implement a summary report on the information provider by the first stored procedure to get such as total OverTimeHourm Total Dollar for each OvertimeReasonID for a time period.
What is best way to implement a SQL stored procedure for my case? Thanks in advance!
Sep 10, 2019 07:37 PM|ryanbesko|LINK
Declare a temp table or table variable. Insert the results of the SP into it. Work with the temp table or table variable to produce your results. This should explain enough to get you started.
Sep 11, 2019 05:19 AM|Yang Shen|LINK
According to your description, you want to use your first stored procedure's result( overtime related information) to be your second stored procedure's parameter?
If so, you might need to check Pass One Stored Procedure’s Result as Another Stored Procedure’s Parameter.
-- Pass One Stored Procedure's Result as Another Stored Procedure's Parameter
DECLARE @ParamtoPass INT, @CircleArea FLOAT
-- First SP
EXEC @ParamtoPass = SquareSP 5
-- Second SP
EXEC @CircleArea = FindArea @ParamtoPass
SELECT @CircleArea FinalArea
In this case, you will just need to EXEC the first SP then EXEC the second one with its result as the first SP's parameter.
If i misunderstood anything, please feel free to let me know.