Showing posts with label email. Show all posts
Showing posts with label email. Show all posts

Monday, March 26, 2012

How to determine OnPostExecute instance

I have a package that sends an email using the OnPostExecute Event Handler. My understanding is that the event is fired once for the package and once for any containers in the package.

I only want to send the email once. Currently I use a variable to count the number of times OnPostExecute is called and only send the email if it is the first time. This is probably not a good long term solution. How can I determine when OnPostExecute is being fired by the package instead of by a container?

Thanks in advance.

Check the SourceName variable. Put a dummy script task in the event handler and put a precedence contraint from the script task to the Send Mail task with the expression "SourceName == PackageName".
|||Which just goes to show that I'd like to see container specific events -- meaning child events don't propagate up.|||

Thanks, Jay. Your recommendation solved the problem.

Code Snippet

If (Dts.Variables("PackageName").Value.ToString = Dts.Variables("SourceName").Value.ToString) Then

'Do something

End If

Phil, I agree. That would be nice.

|||Okay, I just want to make sure I was clear that I wasn't recommending that any code go into the Script Task. As I described it, the Script Task is simply there to allow you to set a precedence between the Script Task and the Send Mail Task. You can then put an expression on the contraint (@.PackageName == @.SourceName) and require that the expression evaluate to true for the dependent task to execute. Then your mail would only be sent if the SourceName of the event was the same as the PackageName. Right-click on the green line and click Edit to see these options.

Wednesday, March 21, 2012

How to detect replication doesnt work and get noticed?

I want to get notice by netsend, email or any other methods
when replication doesn't work or malfunction.
Does anyone know how to do this or any other solution you use for this kind of issue?
Thank you..Every agent that runs your replication (snapshot, logreader, distributot, and queuereader) have associated SQLAgent jobs. All you have to do is modify those jobs by going to Notification tab of the job properties and selecting notification method you'd like to get. You should have an appropriate operator set up before, or you can do it right there by selecting New Operator.|||Thank you for reply..

The main problem I have is how to find out if the replication doesn't work..
I can notice with agent history or icon.

Sometimes the icon become X marked, some times agent keep trying to connect and generate error with forever loop, sometimes gives I/O error while working..

How to find out these and what's best way to find out if replication doesn't work properly?|||Have you looked at what I posted about?|||Yes I did..
I knew that part..
Could you give me more detail with example with specific error cases?
Then, I understand more clearly.|||see attachment|||Thank you for the image..
I think I got it at this level..

I just wonder is there a way to run a custom application when job fails rather than sending Net-send..

Since I have to check hundreds of systems replicated, if I use net-send I will get too much of it and hard to maintain.
If I can run my custome application reporting problem organized, it will be easy to maintain.|||In that case you should create a batch file and call it from task window .

In SQL Scheduler when you click on the task and click advanced it says

" On failure action: and then there is a drop down . All you have to do is add another task to the existing job and call it here

It will say

"On failure Action : Goto Step #2" In that step #2 you can all the windows batch file .. (which can contain anything like ISQL, another program ...)|||Thank you!
I got it!|||Another way of doing it would be to create a custom alert and a scheduled task. When conditions for the alert are met you can invoke that scheduled task that may contain ... see previous post.