当前位置: 代码迷 >> Sql Server >> 请问:sql查询
  详细解决方案

请问:sql查询

热度:21   发布时间:2016-04-27 18:41:44.0
请教:sql查询
我想建个存储过程
想输出一段时间内的记录:
create PROCEDURE GetVisitorsByYear
@Date varchar(50)
AS
BEGIN

SET NOCOUNT ON;
select * from VisitLog where VisitDate between @Date and @Date.year()+1
SET NOCOUNT Off;
END

------解决方案--------------------
SQL code
select * from VisitLog where VisitDate between @Date and dateadd(year,@Date,1)
------解决方案--------------------
SQL code
create PROCEDURE GetVisitorsByYear @Date varchar(50) AS BEGIN SET NOCOUNT ON; select * from VisitLog where VisitDate between @Date and dateadd(year,1,@Date)SET NOCOUNT Off; END
------解决方案--------------------
exec GetVisitorsByYear '2008-01-01'
  相关解决方案