1

I have this sp_send_dbmail script. The error log shows "invalid syntax error".

EXEC msdb.dbo.sp_send_dbmail
    @profile_name = 'PROFILE_NAME',
    @recipients = '[email protected]',
    @subject = ' Search for empty ID result ',
    @query = ' select * from [dbo].[TT_INCI] tt where tt.ts_caseid =''(Auto)'' ',
    @attach_query_result_as_file = 0

Please help

1 Answer 1

2

You need to speficy the database where the table is:

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'DBProfile',
@recipients = '[email protected]',
@subject = ' Search for empty ID result ',
@query = ' select * from [SomeDatabase].[dbo].[TT_INCI] tt where tt.ts_caseid =''(Auto)'' ',
@attach_query_result_as_file = 0

The error message is a bit misleading.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.