I created a small script that works in SQL Server Management Studio, then I created a SQL Server Agent job with that same script; but after I run it, I get an error:
The conversation of a varchar data type to a datetime data type resulted in an out-of-range
I fixed the problem by change the format of date to ISO 8601, but I don't release how my first script works on SSMS and not in SQL Server Agent.
First script:
declare @teste datetime
set @teste = '31/12/2099 00:00:00'
select @teste
Fix error:
declare @teste datetime
set @teste = '20991231 00:00:00'
select @teste