Saturday 16 June 2018

MSSQL - Insert results from stored procedure into temp table

Watch this example on YouTube





Create Table #TemplTable (ProductID int, ProdName varchar(max))
Insert into #TemplTable
Exec [SelectProducts]

select * FROM #TemplTable


stored procedure looks like this:
ALTER PROCEDURE [dbo].[SelectProducts]
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    SELECT ProductID, Name FROM Product
END

No comments:

Post a Comment