【发布时间】:2014-09-21 19:53:15
【问题描述】:
下面的过程只显示我指定为参数的日期,而不是更早的日期。
我指定了@date <= table2.date_column;,但这句话只返回与日期匹配的值,而不是更早的日期
create procedure pro
(
@code int, @date datetime, @total smallint OUTPUT
)
as
begin
select
table1.column1,
table2.date_column
from
table1
inner join
table2 on table1.column1 = table2.column2
where
table1.column1 = @code
and
table2.date_column = @date
and
@date <= table2.date_column;
set @total = @@rowcount;
end
执行
declare @total smallint
exec pro '1', '20140920', @total=@total output
select @total
【问题讨论】:
-
你还有
table2.date_column = @date。拿出来。
标签: sql sql-server datetime stored-procedures parameters