xp_sendmail

  • Does anyone know how to set an attachment path varying by a field in a table?

    Set  @MyAttachments = '\\genesis\E$\ReportPDF\' +(Select OrganizationID from @tempEmail) + '\' +(Select ProjectID from @tempEmail)+ '\' + 'OpenItem.pdf'

    ERROR: Syntax error converting the varchar value '\\genesis\E$\ReportPDF\' to a column of data type int.

    I have it declared on top as:

    Declare @MyAttachments varchar (1000)

     

     

     

  • Select  @MyAttachments = '\\genesis\E$\ReportPDF\' + convert(nvarchar(50), OganizationID ) + '\' + convert(nvarchar(50),  ProjectID)+ '\' + 'OpenItem.pdf'

    from @tempEmail

    _____________
    Code for TallyGenerator

  • What is happening is that the concatenation of a character type and a numeric type results in an integer type in SQL-Land.  So, as hinted in the post above, you need to make sure that all of your numeric values are explicitly converted to a character type before you concatenate them.

     

     

     

  • Thank you!!

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

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