January 12, 2012 at 10:11 am
This is very confusing! why I get error by running this:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'SQL 2005 Email',
@recipients = 'abc@def.com',
@query = 'SELECT COUNT(*) FROM ISCSGSWEBUP01.dbo.ISC_OrgUnitManagers' ,
@subject = 'Work Order Count',
@attach_query_result_as_file = 1 ;
Error:
Msg 22050, Level 16, State 1, Line 0
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 495
Query execution failed: Msg 208, Level 16, State 1, Server ISCSGSWEBUP01, Line 1
Invalid object name 'ISCSGSWEBUP01.dbo.ISC_OrgUnitManagers'.
January 12, 2012 at 10:15 am
so you have a linked server for ISCSGSWEBUP01, right?
did you specify which credentials should be used when accessing it?
could it be that YOU, as a sysadmin, have matching credentials on the link, but the user calling the mail does not?
you might need to add a remote login, perhaps?
Lowell
January 12, 2012 at 10:19 am
It's on the same server.
January 12, 2012 at 10:20 am
removing the server name and dbo is no use
January 12, 2012 at 10:21 am
halifaxdal (1/12/2012)
It's on the same server.
it might still be a permissions issue, though.
if im a user and only have access to production.dbo.Tables, and no access to the ISCSGSWEBUP01 database (which is required due to the dynamic sql) i cannot call the code or a procedure which calls the code.
which user gets the error calling the mail?
Lowell
January 12, 2012 at 10:23 am
I am the admin of the server/db
January 12, 2012 at 10:28 am
halifaxdal (1/12/2012)
I am the admin of the server/db
ok, but where is the code running from? SSMS directly, or part of a job? wouldn't a job might be using a different login/user than yourself?
Lowell
January 12, 2012 at 10:41 am
As the first step, i'm running this as a query n still fail
January 12, 2012 at 11:37 am
Cause identified, my bad. The query is not correct.
I found this by running the query alone, and immediately realized the object part should be: server.database.dbo.table, I missed database there, when I tested it by removing the prefix, it also failed because the send mail command is executed in msdb database.
Thank you Lowell for your time anyway, it is really appreciated.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply