Using a select statement as body of email

  • I am using the sp_send_cdosysmail stored procedure.  The following works fine sending an excel spreadsheet (or more accurately, a link to an excel spreadsheet.)

    But is it possible to put a select statement as the variable @WO? For instance, I would like to send the results of "Select UserLogin, Deptid from tblUser where UserLogin = 'bbridges' "

    Is this possible?

     

    DECLARE @WOs varchar(4000)

    select @WOs = '\\e000472\C$\MailTest.xls'

    EXEC AccurideUtilities.dbo.sp_send_cdosysmail

    'ACCCORPSQ01', -- the "From" in the email

    'me@here.com', -- the "To" in the email

    'Global Database Update Failed', --The "Subject" in the email

    @WOs --The body of the email message

     

    Thanks very much.

    Bob

  • Do you want to send select statement or resultset it returns?

    _____________
    Code for TallyGenerator

  • I want to send the result set that it returns.

Viewing 3 posts - 1 through 2 (of 2 total)

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