I have created the following as an automated job to run at midnight on every database server I manage:
This job fails intermittently on some servers, but not others and I get the following error:
SQL Agent – Jobs Failed: The SQL Agent Job “ucjSQLerrorLogNightlyCycle” failed at Wednesday, November 22, 2017 12:00:00 AM with the error “The job failed. The Job was invoked by Schedule 9 (NightlySQLError). The last step to run was step 1 (SQLErrorLogCycle). – Executed as user: MyDomain\MyServiceAccount. SQLServerAgent Error: The process cannot access the file because it is being used by another process. [SQLSTATE 42000] (Error 22022). NOTE: The step was retried the requested number of times (3) without succeeding. The step failed.”
I receive the following error when I execute
EXEC dbo.sp_cycle_agent_errorlog; in the query analyzer (which wasn’t happening before):
Msg 22022, Level 16, State 1, Line 0 SQLServerAgent Error: The process cannot access the file because it is being used by another process.
I have performed an intensive search on this error message and have not found much of anything. The only gem I found was to use Process Explorer from the SysInternals suite by Mark Russinovich. However, isolating the SQLAgent.exe binary did not show me what other process is using it; the process is lone. I am either performing the incorrect steps or my process is completely wrong.
Other items to note:
- I have verified that another process isn’t running at the same time
- I have ran the job in the middle of the day on a weekend and it will keep running until it fails
- I can copy and paste the code into the SSMS or Toad and the code will execute as expected
- I submitted a ticket to my Infrastructure department to make sure there is an exclusion in the antivirus log folder that SQL Server Agent manipulates.
- I disabled the antivirus and performed the same aforementioned steps with the same result
- Broke the job down into two different steps as Aaron suggested. The code
EXEC sp_cycle_errorlog;works inside of a job and in the query analyzer. The code
EXEC dbo.sp_cycle_agent_errorlog;does NOT work in a job OR in the query analyzer.
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!