0

I have a stored procedure which takes two parameters (two years) to return all the student information during that period in a school. It returns 3 columns i.e BirthYear, Name, Age. I have to store that procedure's output into another table which is holding the same structure. So the table will hold the structure as

BirthYear Name    Age 
---------------------
1988      Joshep  26
2000      John    17

and so on.

Now my procedure is called getAllInfoOfStudent and it takes two parameters which are any two years, getAllInfoOfStudent (1900, 2018) like that .

So my question is how will I get this done? Please help

2 Answers 2

3

If the table has that same structure, and the sp returns just that data, then you need to use INSERT INTO:

INSERT INTO dbo.YourTable
EXEC getAllInfoOfStudent (1900,2018);
Sign up to request clarification or add additional context in comments.

Comments

1

You can use the same logic as you would use to insert into a table from a select statement as long as you have our output from your stored procedure formatted correctly to insert into your table.

INSERT INTO YourTableName    
    EXEC getAllInfoOfStudent 1990, 2018  

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.