Hi,
I have this query that works in query analyser and fails with error 137 when called from sqlagent. Any suggestions?
tks in advance.
This is what I am trying to do...
declare @daysAgo int
declare @runInterval int
declare @currentInterval_h int
declare @currentInterval_m int
set @daysAgo = 3
set @runInterval = 20
set @currentInterval_h = datepart(hh, getdate())
set @currentInterval_m = datepart(mi, getdate())
EXECUTE ('
delete from table
where day(start_time) = day(getdate()- ' + @daysAgo + ')
and datepart(hh, start_time) = ' + @currentInterval_h + '
and
datepart(mi, start_time) <= ' + @currentInterval_m + '
and
datepart(mi, start_time) >= ( '+ @currentInterval_m + '-' + @runInterval + ')
')
I have this query that works in query analyser and fails with error 137 when called from sqlagent. Any suggestions?
tks in advance.
This is what I am trying to do...
declare @daysAgo int
declare @runInterval int
declare @currentInterval_h int
declare @currentInterval_m int
set @daysAgo = 3
set @runInterval = 20
set @currentInterval_h = datepart(hh, getdate())
set @currentInterval_m = datepart(mi, getdate())
EXECUTE ('
delete from table
where day(start_time) = day(getdate()- ' + @daysAgo + ')
and datepart(hh, start_time) = ' + @currentInterval_h + '
and
datepart(mi, start_time) <= ' + @currentInterval_m + '
and
datepart(mi, start_time) >= ( '+ @currentInterval_m + '-' + @runInterval + ')
')