当前位置: 代码迷 >> Sql Server >> 调用存储过程查询指定日期内的生日人员,尽可能sql2000
  详细解决方案

调用存储过程查询指定日期内的生日人员,尽可能sql2000

热度:101   发布时间:2016-04-24 09:52:01.0
调用存储过程查询指定日期内的生日人员,尽量sql2000
生日数据在存储过程里 USP
现不改动存储过程仅调用存储过程表显示内容

code                bir
001                 2003-01-01
002                 1999-06-06
003                 1980-12-12
004                 空
005                 2000-10-10

查询6月1日至11月1日内过生日的人
结果

002        1999-06-06
005        2000-10-10

谢谢!
------解决思路----------------------
假设你的参数格式    ‘0601’     ‘1101’


create procedure proc_GetBirthday(
@startDate varchar(4),
@endDate varchar(4)
)
as
begin
set @startDate='0601'
set @endDate='1101'
select * from tablename where bir btween cast(year(dir) as varchar(4))+'-'+substring(@startDate,1,2)+'-'+substring(@startDate,3,2)  and  cast(year(dir) as varchar(4))+'-'+substring(@endDate,1,2)+'-'+substring(@endDate,3,2)
and dir is not null
end

使用时将两个set语句删掉或注释掉,这里只是做个例子
  相关解决方案