How can I use results from one stored procedure (result is a record set not a single value) in another stored procedure and assign it to a temp table in the second procedure?
Software/Hardware used:
ASKED:
January 4, 2006 5:10 PM
UPDATED:
January 4, 2006 5:36 PM
Declare a TABLE variable and assign results of 2nd stored procedure to it. See code from BOL.
USE AdventureWorks;
GO
DECLARE @MyTableVar table(
EmpID int NOT NULL,
OldVacationHours int,
NewVacationHours int,
ModifiedDate datetime);
UPDATE TOP (10) HumanResources.Employee
SET VacationHours = VacationHours * 1.25
OUTPUT INSERTED.EmployeeID,
DELETED.VacationHours,
INSERTED.VacationHours,
INSERTED.ModifiedDate
INTO @MyTableVar;
–Display the result set of the table variable.
SELECT EmpID, OldVacationHours, NewVacationHours, ModifiedDate
FROM @MyTableVar;
GO
–Display the result set of the table.
–Note that ModifiedDate reflects the value generated by an
–AFTER UPDATE trigger.
SELECT TOP (10) EmployeeID, VacationHours, ModifiedDate
FROM HumanResources.Employee;
GO
Kevin