I have a stored procedure that gathers information about index health and inserts it into a table. The query is joining dm_db_index_physical_stats and sys.indexes. The database contains 2800 tables, so the operation takes 90+ minutes to complete. But it completes successfully when executed using SSMS.
However, a job created to execute the stored procedure fails every time, after about 14 minutes.
The error is:
"The semaphore timeout period has expired. [SQLSTATE 08S01] (Error 121) Communication link failure [SQLSTATE 08S01] (Error 121)."
My question: why would the operation fail, and why timeout so quickly, when executed from SQL Agent? Yet, the same operation is successful when run manually?