Hi
I have a scheduled task that runs a report that updates a table:
declare @max_sales_date date;
declare @month_start_date date;
declare @year_start_date date;
-- set first day of week as Monday
SET DATEFIRST 1;
set @max_sales_date=convert(date,getdate()); set @month_start_date=dateadd(month, datediff(month, 0, @max_sales_date), 0); select @year_start_date=[AccYearSDate] from [pharma].[dbo].[tblAccountYears_v2] where @max_sales_date>=[AccYearSDate] and @max_sales_date<=[AccYearEDate];
update a set a.db_date=@max_sales_date, a.db_value1=b.db_value1, a.db_value2=b.db_value2, a.modified_at=getdate() from pharma.dbo.tblbi_dashboard a join (select 15 as db_type, sum(bal) as db_value1, (select sum(bal) from [pharma].[dbo].[vw_bi_fd_cur_creditors] where comp=2 ) as db_value2 from [pharma].[dbo].[vw_bi_fd_cur_debtors] where Comp=2 ) b on a.db_type=b.db_type;
The issue I'm seeing is that when the report is run via the Scheduled Tasks process that modified_at field, getdate(), doesn't get updated. The Scheduled Tasks shows that it has run OK.
When I run the report directly it does.
Is there a reason you can think of why this is so?
Cheers
Jake