|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL Job datetime comparison problem
Hi, my problem is the following.
I have a stored procedure that runs the following t-sql: delete MYTABLE where DATETIMECOLUMN < dateadd(day,-29,getdate()) If I run this from Query Analizer with EXEC, it works fine. When I run this as a scheduled job it deletes all rows where the date is AFTER dateadd(day,-29,getdate()), which is wrong. The strange thing is, the same scheduled job run on another server works fine. I know Server Agent stores some of its dates in another format. But is this related, ¿why does it work in the other server? Any help appreciated. Cristian |
|
#2
|
|||
|
|||
|
More info
Actually the problem is really this:
1. I open query analizer and connect to a DB server on another IP in the same network. 2. I execute the following statements on a table that has a clustered index (descending) on the column that appears in the where clauses. select * from MYTABLE where DATETIMEFIELD < dateadd(day,-29,getdate()) delete MYTABLE where DATETIMEFIELD < dateadd(day,-29,getdate()) 3. The funny thing is, the above commands do not affect the same rows! 4. If I take away the index, the both commands affect the same rows. 5. The same work fine on another server (with the index). Thanks for any comments. Cristian |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > SQL Job datetime comparison problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|