码迷,mamicode.com
首页 > 数据库 > 详细

MSSQL 日期查询 包含NULL值

时间:2015-11-23 16:51:42      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:

 

 and create_time  >= isnull(@create_time,‘‘2010-01-01‘‘) 
  and create_time  <= isnull(@Endcreate_time,‘‘2200-01-01‘‘)
  and more_dat01 >= isnull(@more_dat01,‘‘2010-01-01‘‘)  
  and more_dat01 >= isnull(@Endmore_dat01,‘‘2200-01-01‘‘)

 

exec sp_executesql Nselect ide_code as ‘‘系统编号‘‘,name as ‘‘申请专利调查名称‘‘,more_str01 as ‘‘项目编号‘‘,org_project as ‘‘应用项目‘‘,button_name2 as ‘‘应用情况‘‘,node_status as ‘‘调查进度‘‘
 ,CONVERT(char(10),create_time,102)as ‘‘申请日期‘‘,CONVERT(char(10),more_dat01,102)as  ‘‘希望完成日期‘‘,CreateUser AS ‘‘申请人‘‘,dept_name AS ‘‘所属部门‘‘, OperatorName as ‘‘调查人‘‘
 ,CONVERT(char(10),end_time,102)  as ‘‘归档完成日期‘‘
,more_txt02 AS ‘‘调查结果‘‘
 from v_HandleZLSTResult 
  where  ide_code like ‘‘%‘‘+@ide_code+‘‘%‘‘  
  and name like ‘‘%‘‘+@name+‘‘%‘‘  
  and more_str01 like ‘‘%‘‘+@more_str01+‘‘%‘‘
  and org_project like ‘‘%‘‘+@org_project+‘‘%‘‘  
and button_name2 like ‘‘%‘‘+@button_name2+‘‘%‘‘    
  and node_status like ‘‘%‘‘+@node_status+‘‘%‘‘   and CreateUser like ‘‘%‘‘+@CreateUser+‘‘%‘‘
  and dept_name like ‘‘%‘‘+@dept_name+‘‘%‘‘and OperatorName like ‘‘%‘‘+@OperatorName+‘‘%‘‘
  and create_time  >= isnull(@create_time,‘‘2010-01-01‘‘) 
  and create_time  <= isnull(@Endcreate_time,‘‘2200-01-01‘‘)
  and more_dat01 >= isnull(@more_dat01,‘‘2010-01-01‘‘)  
  and more_dat01 >= isnull(@Endmore_dat01,‘‘2200-01-01‘‘)

   order by create_time desc,N@ide_code nvarchar(4000),@name nvarchar(4000),@more_str01 nvarchar(4000),@org_project nvarchar(4000),@button_name2 nvarchar(4000),@node_status nvarchar(4000),@CreateUser nvarchar(4000),@dept_name nvarchar(4000),@OperatorName nvarchar(4000)
   ,@create_time nvarchar(4000),@more_dat01 nvarchar(4000),@Endcreate_time nvarchar(4000),@Endmore_dat01 nvarchar(4000)
   ,@ide_code=N‘‘,@name=N‘‘,@more_str01=N‘‘,@org_project=N‘‘,@button_name2=N‘‘,@node_status=N‘‘,@CreateUser=N‘‘,@dept_name=N‘‘,@OperatorName=N‘‘
   ,@create_time=NULL,@more_dat01=NULL,@Endcreate_time=NULL,@Endmore_dat01=NULL

 

MSSQL 日期查询 包含NULL值

标签:

原文地址:http://www.cnblogs.com/Snowfun/p/4988735.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!