#report_tmp中的term_date是char(10),当使用<,>时,它按预期工作,这个比较方法在sybase中是否可靠?
declare @last_year_end char(10)
SELECT @last_year_end=convert(varchar,@cyear -1)+'/12'+'/31'
update #report_tmp
set remark = @note1
where term_date != '' and term_date <= @last_year_end
我宁愿写这段代码:
declare @cur_year datetime
SELECT @cur_year = convert(datetime, convert(varchar, @cyear) + '/01'+'/01', 111)
update #report_tmp set remark = @note1
where term_date != '' and term_date < @cur_year
在将varchar隐式转换为date或datetime时,您不依赖于当前的语言环境设置(可以同时使用)。