Best way to send an email with unmatch data of two tables

  • hi guys i hope you can help me..... i am working with two access databases front end and sql server backend .

    i have a query that makes a comparison of one table in each database and the results are the items that don't  match from table 1 in table 2.

    I need to create a DTS that runs every day that if there are rows in this query then to send an email with the information...

    Can this be done? I could create the queries into sql tasks but not sure what to do next.... please help

     

     

     

  • Try

     Exec Master..xp_sendmail  @recipients = @Precipients

            ,@message = @Pmessage

            ,@query = @Pquery

             ,@attachments = 'Data.xls'

             ,@subject = @Psubject

             ,@attach_results = 'TRUE'

             ,@width = 9999

             ,@separator = @sepchar

             ,@dbuse = @DBName

    Obviuosly you need to declare all the variables and initialise them before calling the Master..xp_sendmail.

    Then you need to set @Pquery to your query. Also this assumes that you properly set up SQL Mail on your server.

  • hi, is there a way to put on the code that if the query shows no results then not to send an email ?

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

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