简体   繁体   中英

Multiple Table Return with Stored Procedure

I have the following stored procedure, it works fine except that when returns all the results it will start over and create another window, it is looping over and over creating table after table with the same results. What could be causing this?

USE [HRLearnDev]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[COL_Run_DOM_Parameters]
@StartDate varchar (50),
@EndDate varchar (50)
AS
SET NOCOUNT ON
SELECT *
FROM dbo.COL_V_GEMS_DOM_FCT
WHERE REC_EFF_STT_DT BETWEEN @StartDate and @EndDate
ORDER BY REC_EFF_STT_DT DESC

EXECUTE COL_Run_DOM_Parameters @StartDate = "2010-03-05", @EndDate = "2011-06-11"

I don't think you want to do this within your stored procedure (ie: REMOVE it):

EXECUTE COL_Run_DOM_Parameters @StartDate = "2010-03-05", @EndDate = "2011-06-11"

This indicates the procedure is calling itself recursively, over and over and over ...

(Unless this was mistakenly included, and was just shown as an example of how you WOULD call the stored proc)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM