有没有办法可以在以下查询中添加时间作为我的电子邮件正文:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'TEST_DEV',
@recipients = 'xxx@gmail.com',
@query = ' select
Percentage = CONVERT(DECIMAL(10,1),100 - (CAST(COUNT(DISTINCT case when PD.Exception != ' ' then PD.Id END) as float)/CAST(COUNT(PD.Id) as float)*100))
from
DataBaseName.dbo.Product P INNER JOIN DataBaseName.dbo.LogProduct PD
ON P.LogId = PD.LogId
WHERE
ResponseTime < GETDATE() and RequestTime > DATEADD(MINUTE, -150, GETDATE())
' ,
@subject = 'Test',
@body = 'Please check the attached file for Providers with Many unsuccessful calls between the time xx an yy',
@attach_query_result_as_file = 1 ;
在当前行
@body = 'Please check the attached file for info on calls between the time xx an yy',
我想添加 GetDate() 代替 xx 和 DATEADD(MINUTE, -150, GETDATE()) 代替 yy ?
可能吗 ?
declare @body nvarchar(max)
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'DEV',
@recipients = 'xxx@gmail.com',
@query = 'exec Database.dbo.spTest' ,
@subject = 'Test',
select @body = 'Please check the attached file for info on calls between the time ........................',
@attach_query_result_as_file = 1 ;
你想让我做这样的事吗?