How to add email address in a t sql code

  • Also, i want the results in body , not in as an attachment.

    Thanks.

    Regards,

    Sushant

    Regards
    Sushant Kumar
    MCTS,MCP

  • SKYBVI (3/4/2011)


    Also, i want the results in body , not in as an attachment.

    Thanks.

    Regards,

    Sushant

    please try both code snippets i pasted; one does exactly what you are asking by putting a query in the email body, the other does it as an attachment.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • SKYBVI (3/4/2011)


    Also, i want the results in body , not in as an attachment.

    Thanks.

    Regards,

    Sushant

    Sushant, if you look up sp_send_dbmail in BOL (Books Online, SQL Server's help) you will find the meaning of every single parameter.

    I know that asking here and being spoon-fed is much easier, but this way you hardly learn something.

    The parameter you're looking for is this one:

    @attach_query_result_as_file

    -- Gianluca Sartori

  • Gianluca Sartori (3/4/2011)


    SKYBVI (3/4/2011)


    Also, i want the results in body , not in as an attachment.

    Thanks.

    Regards,

    Sushant

    Sushant, if you look up sp_send_dbmail in BOL (Books Online, SQL Server's help) you will find the meaning of every single parameter.

    I know that asking here and being spoon-fed is much easier, but this way you hardly learn something.

    The parameter you're looking for is this one:

    @attach_query_result_as_file

    I am not getting spoon fed, but iam having errors evertime i run the code, thts why , i want to know.

    OKay, I will look at the parameter too..

    Regards,

    Sushant

    Regards
    Sushant Kumar
    MCTS,MCP

  • OK ..

    Now when i run hte code there is an error in hte line below:-

    LEFT(LTRIM(RTRIM(IM.ITEMNMBR)), (CHARINDEX('-', LTRIM(RTRIM(IM.ITEMNMBR))) - 1)),

    The error says :-

    Incorrect syntax near '-'.

    BUT when i run this code(t-sql) separetly, it runs fine...

    Wondering..

    Regards,

    Sushant

    Regards
    Sushant Kumar
    MCTS,MCP

  • if we are going to help with syntax, you have to paste the entire script you are trying to use.

    remember we are not standing in your cubicle looking over your shoulder. we cna see only what you report here; everything you've posted so far is disjointed, or comments like "it doesn't work"

    help us help you.

    SSMS is kind enough to tell you the error and line number, usually that is enough to do it yourself, but if you are stuck, show us the entire code block.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 6 posts - 16 through 20 (of 20 total)

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