Solved

SQL Agent Job sometimes failes

Posted on 2009-07-13
6
390 Views
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
WHERE DATEDIFF ...
AND ...
 
 
INSERT INTO ...
SELECT ...
FROM #tmpTable
GROUP BY ...
 
drop table #tmpTable

Open in new window

0
Comment
Question by:ALSO_DB
[X]
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
6 Comments
 
LVL 143

Accepted Solution

by:
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

0
 

Author Comment

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

Author Comment

by:ALSO_DB
ID: 24878639
No helpful answer recieved...
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:ALSO_DB
ID: 24878640
No helpful answer recieved...
0
 

Author Comment

by:ALSO_DB
ID: 24878642
No helpful answer recieved
0
 

Author Comment

by:ALSO_DB
ID: 24878646
No helpful answer recieved...
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

615 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