日期:2014-05-18  浏览次数:20430 次

sql 存储过程那位大神帮我看看那块出错了?
PRINT ' ==================== creating Procedure SP_QUERY_TOPDIARY1 =================== '
GO
/*
编号:**** 名称: SP_QUERY_TOPDIARY1
功能:

*/
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'SP_QUERY_TOPDIARY1' )
  DROP PROCEDURE SP_QUERY_TOPDIARY1
GO
CREATE PROCEDURE SP_QUERY_TOPDIARY1 @IN_SERIAL_NO INT,
  @IN_OP_CODE INT,  
  @IN_DIARY_TYPE INT, --日周志类型
  @IN_START_DATE INT, --开始日期
  @IN_END_DATE INT --结束日期
WITH ENCRYPTION
  AS
  IF ISNULL(@IN_SERIAL_NO,0) <>0
SELECT A.*,B.OP_NAME
    FROM TOPDIARY A,TOPERATOR B
  WHERE A.SERIAL_NO = @IN_SERIAL_NO
  ELSE
  SELECT A.*,B.OP_NAME
  FROM TOPDIARY A,TOPERATOR B 
  WHERE OP_CODE=@IN_OP_CODE OR ISNULL(@IN_OP_CODE,0)=0
  AND(DIARY_TYPE =@IN_DIARY_TYPE OR ISNULL(@IN_DIARY_TYPE,0) =0)
  AND (DIARY_DATE >= @IN_START_DATE OR ISNULL(@IN_START_DATE,0) =0)
  AND(DIARY_DATE <= @IN_END_DATE OR ISNULL(@IN_END_DATE,0) =0)
  ORDER BY SERIAL_NO
   
GO


------解决方案--------------------
WHERE OP_CODE=@IN_OP_CODE OR ISNULL(@IN_OP_CODE,0)=0
表的连接查询有问题。
------解决方案--------------------
同意楼上。
------解决方案--------------------
同意楼上。