Can it be done? Send individual emails using SPROC.

  • I'm wondering if this can be done and if so, how. I'm on SQL 2012.

    Let's say I have 2 tables. 1st table has names and emails. There are 20 sales reps and their email in this table. The 2nd table has their names and sales.

    What I'm wondering is if a sproc can be written that loops through the list of name joined to the sales table, to send each rep an email, with just their own sales. I don't want the other sales reps seeing sales that are not theirs.

    So whenever the sproc is executed, Jon, Jane, Mike, Mary ... etc would get a email with only their own sales.

    Can it be done and if so, anyone have a sample SPROC?

    Thanks!

  • This sounds like a textbook case for SSRS subscriptions. Are you sure you want to go "old school" on this one?

    https://msdn.microsoft.com/en-us/library/ms159762.aspx

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Right now, they're using SSRS, but I was told they're have a separate report for each and every rep... Basically they're saying they can't loop through a table and send individual emails.. Me, I'm not familiar with SSRS so I can't say how or even if it can be done. If you can point me in a direction on how it to accomplish this in SSRS, it would be great. If not, I need to figure on the old school way of doing it was s SPROC.

    Thanks!

  • This is all about setting up a "data-driven subscription".

    It's been a while since I've had the pleasure of doing it but the basics are covered here:

    http://beyondrelational.com/modules/2/blogs/101/posts/13460/ssrs-60-steps-to-implement-a-data-driven-subscription.aspx

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

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

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