发送查询结果
这会附加查询 SELECT * FROM Users
的结果并将其发送到 recipient@someaddress.com
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'The Profile Name',
@recipients = 'recipient@someaddress.com',
@query = 'SELECT * FROM Users',
@subject = 'List of users',
@attach_query_result_as_file = 1;