在sp_send_dbmail之前检测文件大小 [英] Detecting file size before sp_send_dbmail
本文介绍了在sp_send_dbmail之前检测文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们正在使用以下附件,附件限制为10MB.
We're using the following with a 10MB limit for attachments.
EXEC msdb..sp_send_dbmail
@recipients = 'me@me.co.uk',
@subject = 'foo bar',
@file_attachments = 'C:\xxx\yyy\myFile.xlsx,
@body_format = 'html',
@body = 'norf';
在运行此脚本之前,是否可以在SQL Server脚本中检查myFile.xlsx
的大小?
Is it possible in the SQL Server scripts to check the size of myFile.xlsx
before running this script?
推荐答案
我有一个使用批处理文件的解决方案:
I have a solution by using Batch Files:
[C:\ FileSize.cmd]
@echo %~z1
现在您可以通过使用该文件来获得<your_file>
的大小:
Now you can get size of <your_file>
by using that file:
DECLARE @t table(filesize int)
INSERT INTO @t
EXEC [xp_cmdshell] @command_string = 'C:\filesize.cmd <your_file>'
SELECT TOP(1) * FROM @t
这篇关于在sp_send_dbmail之前检测文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文