开发者

SQL Server 2000 Stored Proc bombing for no apparent reason

开发者 https://www.devze.com 2023-02-20 00:34 出处:网络
On the if it bombs or some error always - any help would be so greatly appreciated. CREATE PROCEDURE sp_LetsWork

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消