当前位置: 代码迷 >> Sql Server >> 帮小弟我看看这个SQL的存储过程为什么运行不了
  详细解决方案

帮小弟我看看这个SQL的存储过程为什么运行不了

热度:336   发布时间:2016-04-27 21:59:18.0
帮我看看这个SQL的存储过程为什么运行不了
SET   QUOTED_IDENTIFIER   ON  
GO
SET   ANSI_NULLS   ON  
GO

ALTER     procedure   CombinedSearch
@StartTime   smalldatetime,
@EndTime   smalldatetime,
@empState   varchar(100)=   null
as
if   @empState <> null
select   *   from   jobseeker
where   (@StartTime <=InterviewTime   and   @EndTime> =InterviewTime)   and   [email protected]
else   if   @empState=null
select   *   from   jobseeker
where   (@StartTime <=InterviewTime   and   @EndTime> =InterviewTime)  

GO
SET   QUOTED_IDENTIFIER   OFF  
GO
SET   ANSI_NULLS   ON  
GO
[email protected]?[email protected]?[email protected]?的结果的。请各位看看。

------解决方案--------------------
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

ALTER procedure CombinedSearch
@StartTime smalldatetime,
@EndTime smalldatetime,
@empState varchar(100)= null
as
if @empState is not null
select * from jobseeker
where (@StartTime <=InterviewTime and @EndTime> =InterviewTime) and [email protected]
else if @empState is null
select * from jobseeker
where (@StartTime <=InterviewTime and @EndTime> =InterviewTime)

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
------解决方案--------------------
汗, 不能用 <> NULL, =NULL 來判斷的
  相关解决方案