
IF EXISTS(SELECT * FROM SYS.PROCEDURES WHERE NAME='PROC_INQUIRE_PLANPLMRPT')
	DROP  PROCEDURE  dbo.PROC_INQUIRE_PLANPLMRPT;
GO
	
CREATE PROCEDURE PROC_INQUIRE_PLANPLMRPT
	@STARTDATE date
	,@ENDDATE date
	,@LCID int
	,@SeqFld varchar(200)
	,@HasId int output
AS 
BEGIN
	set @hasId = 0;
	IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[T_PLAN_PLANPLMRPT]') AND type IN ('U')) 
		begin
			SELECT 
				@HasId = COUNT(A.FID) 
			FROM 
				T_PLAN_PLANPLMRPT A
			WHERE
				A.FDATE BETWEEN @STARTDATE AND @ENDDATE		
		END

	if @hasId =1
		BEGIN
			SELECT 
				*
				INTO #TMPMPS 
			FROM 
				T_PLAN_PLANPLMRPT A
			WHERE
				A.FDATE BETWEEN @STARTDATE AND @ENDDATE		
		END
END