语句不难写啊。
不过想提醒一下,最好是不要让SQL SERVER自动做这样的结帐操作。在应用程序里让用户手工操作好些。
因为一般不好保证在每月一号一定能满足结帐的条件。手工操作也只需要一个月一次,也不是什么麻烦事。
不过想提醒一下,最好是不要让SQL SERVER自动做这样的结帐操作。在应用程序里让用户手工操作好些。
因为一般不好保证在每月一号一定能满足结帐的条件。手工操作也只需要一个月一次,也不是什么麻烦事。
create proc aaaa
@m datetime
as
declare @startdate datetime
select @startdate=convert(datetime,convert(char(6),@m,112)+'01')insert yfyt(
yhm,
ljll,
zfy,
yf,
nf
)
select
clientusername as yhm,
sum(xjll) as ljll,
sum(fy) as zfy,
month(@startdate) as yf,
year(@startdate) as nf
from wljf
where logdate>=@startdate
and logdate<dateadd(month,1,@startdate)
group by clientusernamego
输入的时间格式是什么样才对呢!
我在事件分析器里进行如下操作:
execute aaaa 2002-9-1
结果提示:
服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: '-' 附近有语法错误。希望你能给与帮助!!!
execute aaaa '2002-9-1'