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
Solved

SQL Agent Job sometimes failes

Posted on 2009-07-13
6
378 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 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

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.

Question has a verified solution.

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

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 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