Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Database mail sending fails with SP_Send_DBmail.

$
0
0
Hi,

I am stuck in below problem.

I have two servers; ServerA and ServerB. I have linked serverA to serverB by
sp_addlinkedserver @server = 'serverB',@provider = 'SQLNCLI',@datasrc = 'ServerB',
@srvproduct = '' on serverA. Now I am querying on ServerA and retriveing data from ServerB's Table.
The Query is :

EXEC msdb.dbo.sp_send_dbmail @recipients = 'myname@myDomain.com',
@subject = 'MySubject',
@body = 'This Is Test.',
@body_format = 'Text', @profile_name = 'Profile1',
@query = 'set nocount on
SELECT * FROM [ServerB].[Database].dbo.myTable AS MT
WHERE DATEADD(DAY,0,DATEDIFF(DAY,0,Date_Col)) = DATEADD(DAY,0,DATEDIFF(DAY,0,GETDATE()))',
@execute_query_database = 'master',
@query_result_separator = ' ',
@attach_query_result_as_file = 1,
@query_attachment_filename = 'myFile.csv'

I have created an proc on serverA's master database and calling this proc into a job.
This job throws an error:

" Executed as user: ServerA\sqlAgent. Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. [SQLSTATE 28000] (Error 18452). The step failed. "

Can Anybody help in solving this??
It would be a great help.

Thanks and Regards,
Jignesh

Viewing all articles
Browse latest Browse all 13329

Trending Articles