我有這個存儲過程調用其他第二個存儲過程,它返回一個包含5列的表。我將結果插入到第一個存儲過程的臨時表中。這個想法是在一個Crystal Report中顯示這個表,所以我需要這個存儲過程來返回臨時表。存儲過程的返回表
我怎樣才能讓它返回5列和值的表?
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[paBltBuscarBoletasASA] @id_Asa int
-- Add the parameters for the stored procedure here
AS
DECLARE @Query int
CREATE TABLE #tablaTemporal (Numero_Pregunta varchar, Numero_Boleta int, Cultivo varchar, Numero_Siembra int, Detalle_Error varchar)
DECLARE miCursor CURSOR FOR
SELECT
localizacion.c_Fk_IdBoleta
FROM
Blt_Boleta as boleta, Fnc_Localizacion as localizacion
WHERE
boleta.c_Pk_IdBoleta = localizacion.c_Fk_IdBoleta AND
localizacion.si_CodAsa = @id_Asa
OPEN miCursor
FETCH NEXT FROM miCursor INTO @Query
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #tablaTemporal(Numero_Pregunta, Numero_Boleta, Cultivo, Numero_Siembra, Detalle_Error) exec dbo.paBltMarcarErroresBoleta @Query
FETCH NEXT FROM miCursor INTO @Query
END
CLOSE miCursor
DEALLOCATE miCursor
+1:唔...你想完了那個之後一定很累;) –