top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

SQL: How to SELECT * INTO [temp table] FROM [stored procedure]

+4 votes
1,030 views
SQL: How to SELECT * INTO [temp table] FROM [stored procedure]
posted May 28, 2014 by Khusboo

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Lets have one example for same:

Let's suppose you want a stored procedure to return a list of all the people with a given last name. The code for the stored procedure might look like this:

CREATE PROCEDURE dbo.GetPeopleByLastName (@LastName NVARCHAR(50))
AS
SELECT ContactID,
    FirstName,
    LastName
FROM Person.Contact
WHERE LastName = @LastName
ORDER BY ContactID
answer Jun 3, 2014 by Amit Kumar Pandey
Thanks.. But I want to add the selected rows in a new table. Sat a new table i have created having same columns.. Now i want data retrieved by this sp to be entered in that table.
...