I am getting an error while trying to execute the following querry

  • Hi all ,

    I am getting an error while trying to execute the following querry

    ************************************************

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'Anup',

    @recipients = 'devi.parvathaneni@abs.in',

    @query = 'SELECT COUNT(*) FROM [Telsima Communications Pvt Ltd$Sales Line]

    WHERE (Amount > 0)',

    @subject = 'Error Log Count',

    @attach_query_result_as_file = 1 ;

    *******************************************

    it gave me this error

    *********************************

    Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 476

    Query execution failed: Msg 208, Level 16, State 1, Server ANUP, Line 1

    Invalid object name 'Telsima Communications Pvt Ltd$Sales Line'.

    Msg 0, Level 11, State 0, Line 0

    A severe error occurred on the current command. The results, if any, should be discarded.

    *************************************************************

    could any one let me know wht might be the problem

  • Please check whether the table Telsima Communications Pvt Ltd$Sales Line is available or not?

  • With dbmail you should qualify your object 3-part way

    select xyz, abc from [db].[schema].[objectname]

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • thanks for your inputs

    i shall try out and let you know

  • Using the 3-part name surely resolved my issue for sp_send_dbmail

    In quote was the error I got

    "Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 476

    Query execution failed: Msg 208, Level 16, State 1, Server serverName\instanceName, Line 1

    Invalid object name 'dbo.old_tblSomething'.

    Msg 0, Level 11, State 0, Line 0

    A severe error occurred on the current command. The results, if any, should be discarded."

    Thanks ALZDBA

  • sp_send_dbmail stored procedure is in the msdb database. For this reason, you have to provide the databasename, SchemaName and Objectname in order to hit the right object.

    Atif Sheikh

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • hth

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply