On the if it bombs or some error always - any help would be so greatly appreciated.
CREATE PROCEDURE sp_LetsWork
(@MYID int, @ThisDate Datetime)
AS
SET NOCOUNT ON
DECLARE @intErrorCode int,
@QStartDate datetime,
@QEndDate datetime
SELECT @intErrorCode = @@ERROR
--DATEPART(mm, @ThisDate) BETWEEN 1 and 3 -- test both options
BEGIN
IF @ThisDate BETWEEN '01/01/' + CONVERT(VARCHAR(4), YEAR(@ThisDate))
AND '03/31/' + CONVERT(VARCHAR(4), YEAR(@ThisDate))
RunQuarter:
SELECT *
FROM qryAR
WHERE CID = @MYID
AND (paid开发者_开发问答date >= @QStartDate
AND paiddate <= @QEndDate)
--ORDER BY paiddate ASC
GO
-- GOTO RunQuarter
END
GO
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO ErrHandler
RETURN 0
ErrHandler:
RETURN @intErrorCode
GO
You have a GO
halfway in the stored proc.
GO
is not SQL: it tells client tools like SSMS where a batch ends
So the error is after paiddate <=@QEndDate)
because this is the end of the stored proc because of GO
: there is no matching END
for the BEGIN
above this
It isn't "bombing" on execution because it isn't being created...
精彩评论