Format file attached by xp_sendmail

  • Hi,

    I am having problems when attaching the results of a stored procedure using the xp_sendmail extended procedure. The file that is attached does not stay in the 3 column format displayed in Query Analyser when you execute the stored procedure. The attachment is also full of white spaces.

    Can anyone help?

    Regards

    Steve

  • This was removed by the editor as SPAM

  • Are you defining a specific separator?  If not try defining it as a comma and you should get a comma delimited attachment that should be easy to open with spreadsheets and the like.

    If the phone doesn't ring...It's me.

  • Make sure you have the @width parameter set or you'll encounter formatting issues like the one you mentioned.

    For example:

     

     exec master..xp_sendmail @recipients = @v_RecipientList,

         @query = @v_sql,

         @attach_results = 'true',

         @message = @v_msg,

         @width = 2000,

         @subject = @v_sub,

         @attachments = 'PointsByEmployee.txt'

    And as Charles mentioned, use @separator if necessary.  Check SQL Books On-Line for more options.

  • Thanks for you help guys. Have it sorted now.

    Cheers

    Steve

Viewing 5 posts - 1 through 4 (of 4 total)

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