下面是我的工作我的存储过程创建“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)。 –