下面是我的工作我的存儲過程創建「ListDailyInbound855-InputScript.sql 第一份工作(生成文件)創建輸出中。 「d:\ DailyReports \ Inbound855.txt」如何檢查SQL腳本中的文件是否爲空?
sqlcmd -i D:\InputSQLScripts\ListDailyInbound855-InputScript.sql
-S localhost -E -s " " -o D:\DailyReports\Inbound855.txt
第二職業(郵件文件)創建一個電子郵件發送出去[email protected]
Declare @ExeFilePath varchar(255)
Set @ExeFilePath = 'D:\Applications\EmailUtility\Mailer '
Declare @cmd varchar(500)
Set @cmd = @ExeFilePath + ' "Host:smtp.emailserver.com" "To:[email protected]
company.com" "Cc:[email protected] company.com" "From:[email protected] company.com"
"Disp:EDI Support" "Sub: Daily Inbound 855 Report" "Msg:Please find
report attached." "Atch:D:\DailyReports\Inbound855.txt"'
Declare @output int
Exec @output = master..xp_cmdshell @cmd,no_output
If @output <> 0
Begin
RaisError('Error while sending email.', 16, 1)
Return
End
問題:我需要先檢查輸出「d:\ DailyRe ports \ Inbound855.txt「在使用它作爲電子郵件的附件 之前是非空的,因此不會將其作爲空的接收。我的目標是隻有在附件有內容或非空時纔會收到電子郵件警報。任何幫助表示讚賞。
從採用主'。 .xp_cmdshell'這可能是一個SQL Server問題,但如果您將問題標記爲可能會有幫助(可能使用正確的版本:運行SELECT @@ VERSION)。 –