我有一個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