• kpmandani (12/2/2016)


    I want to send a csv file using SQL Server only when it has more than 1 record present in it. Daily this file is getting cleared and updated with new records (if any comes). First row is appended with headers and so I want to achieve something of this kind:

    if rowcount (file.csv)>1

    {

    send csv file as email

    }

    else

    {

    do nothing

    }

    end

    I know there is store procedure called sp_send_dbmail in msdb but I do not know, how I can use this store procedure into my desired scenario.

    Would be glad to receive any help on it.

    Presumably you are populating the file using a data flow? If so, add a record count transformation into the data flow to save the record count to an int variable (which you will have to create first).

    Use a precedence constraint (condition: RCVariable > 1) to control whether the e-mail gets sent or not.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.