I am trying to send an email with the results in the body of the message. Below is the code and below that is the error.
DECLARE @mailprofile VARCHAR(200)
declare @query nvarchar(max)
SET @query = 'select top 1 AccountID from operations.dbo.Accounts'--'select SQL from operations..ChangeAttempt'
SET @mailprofile = (SELECT top 1 name FROM msdb.dbo.sysmail_profile)
EXEC msdb.dbo.sp_send_dbmail
@profile_name = @mailprofile,
@recipients = 'anaylor@lamar.com',
@query = @query,
@subject = 'Current Test EMAIL' ;
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 517
Query execution failed: Msg 15404, Level 16, State 19, Server SQLDEVELOPMENT2, Line 1
Could not obtain information about Windows NT group/user 'LAMARHQ\anaylor', error code 0x6e.
Alan