SQL Agent Job sometimes failes

Posted on 2009-07-13
Last Modified: 2012-05-07
We have a SQL Agent Job which runs every day (at night). Sometimes this job failes at one step with the following error message:

"Unspecified error occurred on SQL Server. Connection may have been terminated by the server. [SQLSTATE HY000] (Error 0) " .

At this time nothing is going on on the database!
The step which failes executes an Stored Procedure.
Here is the Code of that Stored Procedure:
DELETE FROM table WHERE DATEDIFF (dd, column, getdate()) = @iAnzahlTage)
SELECT table, table2, var1 = convert(varchar(8), ...)
INTO #tmpTable
FROM Table
AND ...
FROM #tmpTable
drop table #tmpTable

Open in new window

Question by:ALSO_DB
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 500 total points
ID: 24846949
>DELETE FROM table WHERE DATEDIFF (dd, column, getdate()) = @iAnzahlTage)
should be better:
DELETE FROM table WHERE column < DATEADD (dd, - @iAnzahlTage, getdate()) 
same expression should be used on the other WHERE clauses, and ensure you have a index on the column...

Open in new window


Author Comment

ID: 24849949
That comment didnt help me to find a solution, why does this Job failed sometimes and sometimes its having no failure...!!!

Author Comment

ID: 24878639
No helpful answer recieved...
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 24878640
No helpful answer recieved...

Author Comment

ID: 24878642
No helpful answer recieved

Author Comment

ID: 24878646
No helpful answer recieved...

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question