Solved

SQL Agent Job sometimes failes

Posted on 2009-07-13
6
375 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
  • 5
6 Comments
 
LVL 142

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 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