Query Server and send Results

  • I'm new to the SQL world in some regards, but falling back on my other programming experience the transition is not all that difficult. I have a challenging situation that I am more so looking for suggestion on how it would be best handled.

    I have a DB used for work that issues requests to many different groups. At the same time we gather business intel from our sales staff. I have a query built that pulls the info and sorts it as needed. What i want to do is send an email from the server to each salesperson with their results.

    As an example my query now pulls 354 rows of data back, but one salesperson only has 8 rows of results. I don't want the email going to this sales person to contain it all, just his. Any suggestion on how to accomplish something of this sort?

    If this would require a loop of some sort with IF's you might need to point me in some direction to help get me going.

    Thanks in advance.

  • If you have SSRS available, I'd set up a report that is based off of the login, and have each user schedule to run it.

    If you want to do this from a job, look into the sp_send_dbmail stored procedure.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

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

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