【发布时间】:2009-03-18 15:31:13
【问题描述】:
我在 SQL Server 2008 中使用 sp_send_dbmail 发送查询结果。我将查询移动到一个过程中,并试图在 sp_send_dbmail 过程中使用过程,如下所示:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'myprofile',
@from_address = 'email@somedomain.com',
@reply_to = 'email@somedomain.com',
@recipients = 'email@differentdomain.com',
@importance = 'NORMAL',
@sensitivity = 'NORMAL',
@subject = 'My Subject',
@body = 'Here you go.',
@attach_query_result_as_file= 1,
--@query_result_header = 1,
@query_result_width = 1000,
@query_result_separator = '~',
@query_attachment_filename = 'myFile.txt',
@query = 'EXEC dbo.myProc'
我也尝试过在 proc 上使用 4 部分命名;有和没有'EXEC'等。它作为一个查询工作得很好,但我似乎无法让它作为一个proc工作。这甚至可能吗?
【问题讨论】:
标签: sql sql-server email stored-procedures