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

请教: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'