0

我已经为这个问题准备了尽可能多的答案,但无法提出解决方案。

我们最近将我们的应用程序从 SQL 2008 移到了 2012。这在 2008 年没有问题。

我只会添加我认为存在错误的 SP 部分,当运行此存储过程时,我收到上述错误消息,@startdate 为 2014-02-01,@enddate 为 2014-02-28。

ALTER PROCEDURE [dbo].[Action_UpdateRProfitabilityReportTable9-21-09]
@startdate datetime,
@enddate datetime,
@vehiclemaintence float,
@fleetops float,
@driverrate float,
@helperrate float,
@fuelrate float

AS



INSERT INTO [dbo].[rprofitabilityreport]

(Route, Material, Helper, monthofyear, monthyear, sitecount, totalstops , RecurringRevenue, WORevenue, DumpTons, DumpFees,
FuelPumped, Miles, TotalHours, FuelCosts, VehicleMaintence, FleetOPs, LaborCosts,
BenefitFactor, ActualDumpRate, RouteExpenses, RouteExpensesperStop, CardboardDump, MixPaperDump) 




left join (select distinct sh.route, sh.routemonth, sh.monthyr, count(sh.siteid) AS SiteCount
from (select sh.siteid, sh.route, datepart(mm,sh.servicedate) AS RouteMonth, left(cast(datepart(yyyy, sh.servicedate) as varchar(4)),4) + '-' + right('00' + cast(datepart(mm, sh.servicedate) as varchar(2)),2) AS MonthYR, count(sh.servicehistoryuid) As RouteCount
from [dbo].[ServiceHistory_vw_With_ServiceUID] sh
where sh.servicedate between @startdate and @enddate
group by sh.siteid, sh.route, datepart(mm,sh.servicedate), datepart(yyyy, sh.servicedate)) as sh
group by sh.route, sh.routemonth, sh.monthyr) rc ON rc.route = a1.route and rc.monthyr = a1.monthyr) RS
4

0 回答 0