Link to home
Start Free TrialLog in
Avatar of onaled777
onaled777Flag for United States of America

asked on

Debugging apparent syntax error on Create Stored Procedure Statement

Something is wrong with my syntax in the create stored procedure function in the code below.

It keeps giving the following error on the 28th Line which says:       select COUNT(*)

Can anyone point out why?


USE [TRT]
GO

/****** Object:  StoredProcedure [dbo].[usp_SurveyBNBPopulationSize]    Script Date: 04/04/2010 13:22:27 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER OFF
GO


CREATE PROCEDURE [dbo].[usp_SurveyBNBPopulationSize](
	@StartDate	datetime,
	@Debug		bit	=null)
AS

BEGIN

	set nocount on

	declare	@ReturnValue	int

	select	@ReturnValue	=1,
			@Debug			=isnull(@Debug,0)
		
	begin
	select COUNT(*)
	from Orders o (nolock)
	join Customers c (nolock) on c.Customer_ID=o.Order_ID
	where DateDiff(day, o.NextBillDate, @StartDate) = 0
	and exists (select 1 from SVYResponses r1 (nolock) where o.Order_ID=r1.Order_ID and GETDATE() < (DATEADD(DD,30,r1.Datesubmitted)))
	and (select COUNT(*) from SVYResponses r2 (nolock) where o.Order_ID=r2.Order_ID) >= 5
	and not exists (select 1 from Prefs p (nolock) where o.Order_ID=p.Order_ID and p.Active=1 and SVYF_ID=4)
	and c.MemberTypeCode in (1,3)
	--option (maxdop 1)

	if @Debug=1	print convert(char(40),'BNB Population Size Estimate') + convert(char(10),@ReturnValue) )
	end
	
return	@ReturnValue
END

GO

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>Can anyone point out why?<<
Did you not see the extra paranthesis underlined in red?
Avatar of onaled777

ASKER

Thanks chapmandew that worked perfectly.

No acperkins I definitely did not and still do not see any area of the script in red.
Fair enough.  You must not be using intellisense.