我有一个SQL Server代理作业正在运行,它使用存储过程来执行多个操作,然后将一些数据导出到xls电子表格并发送电子表格。它的大部分工作时间,但好几次了一个月的工作失败,错误:没有详细信息的SQL Server OLEDB错误
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider did not give any information about the error. [SQLSTATE 42000] (Error 7399). The step failed.
感谢,微软,对于详细的错误信息。无论如何,短期修复通常是简单地重新执行工作。通常这会起作用,但在极少数情况下它不会,我必须重新启动SQL Server实例。
这里是我的代码如何与OLEDB交互:
Insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 5.0;Database=\\Excel\POStatus\POStatus.xls;',
'SELECT * FROM [POStatus$]')
Select --Tons of columns with tons of math and functions
FROM --5 tables joined together (left joins)
WHERE -- Tons of where conditions
Order by --Case statement for custom sorting
Set @vCommand = 'copy \\Excel\POStatus\POStatus.xls \\Excel\POStatus\POStatus_' + @vDate + '.xls'
EXEC master..xp_cmdshell @vCommand , NO_OUTPUT
... omitted for brevity...
Set @nvSubject = ' POStatus ' + @vDate
Set @nvMessage = ' This is an automated message, please respond to the IS department, thank you '
Set @nvMessage = @nvMessage + char(13) + char(10)
Set @nvAttachments = '\\Excel\POStatus\POStatus_' + @vDate + '.xls'
Exec master..xp_sendmail
@recipients = @nvRecipients , @copy_recipients = @nvCopy_recipients ,
@subject = @nvSubject , @message = @nvMessage ,
@query = @nvQuery , @width = @iWidth , @attachments = @nvAttachments
那么,这个又是什么原因,我该怎么预防呢?
副本是否成功?可能需要关闭'xp_cmdshell'上的'NO_OUTPUT'来找出:-) – Bridge
您的意思是,当整个操作失败时复制是否成功?我不知道。但我会在下次发生故障时检查。 – MAW74656