我有一個作業設置,當磁盤空間低於20%時發送電子郵件。現在,除了電子郵件中的結果之外,一切都很好。我試圖將query_result_width更改爲每種可能的變體。我想以純文本的形式發送它,因爲某些上層電子郵件出於某種原因只能用純文本。這些行看起來像是在其他行上生成的,並且結果如下,結果就是一個例子。SQL電子郵件行未對齊
ServerName Drive
Free(MB)
MyServerName C
5,468
應該像這樣:
ServerName Free(MB) Drive
MyServerName 5,468 C
下面是使用腳本,任何幫助將不勝感激。
execute msdb.dbo.sp_send_dbmail
@profile_name = 'ProfileName',
@recipients = '[email protected],
@subject = 'WARNING: Disk space in one or more drives is below 20 % free space',
@body_format = 'TEXT',
@Body = 'These are the servers and drives with low free space',
@query_result_width = 134,
@query_result_header = 0,
@query ='SET NOCOUNT ON;
SELECT "ServerName" as [ServerName], "Drive" as [Drive], "Total(MB)" as [Total(MB)], "Free(MB)" as [Free(MB)], "Used(MB)" as [Used(MB)], "Free(%)" as [Free(%)]
UNION ALL
SELECT [ServerName]
,[Drive]
,[Total(MB)]
,[Free(MB)]
,[Used(MB)]
,[Free(%)]
FROM [DBA].[dbo].[ServerDriveSpace]
WHERE [Free(%)] < 20'