I have a stored procedure that gets data from different tables. I want a few fields from the result set of the stored procedure to be inserted on another table.
How can I do this? Cursor, another stored procedure or what?
I have a stored procedure that gets data from different tables. I want a few fields from the result set of the stored procedure to be inserted on another table.
How can I do this? Cursor, another stored procedure or what?
You can insert the result set from a stored procedure into another table, as in this example from this article:
DECLARE @People TABLE
(
ContactID INT,
FirstName NVARCHAR(50),
LastName NVARCHAR(50)
)
INSERT @People (ContactID, FirstName, LastName)
EXEC dbo.GetPeopleByLastName @LastName = 'Alexander'