SSIS and SQL Server Agent Job Notification duplicates the error mail - sql-server

I have an interesting issue. I will try to keep it simple as explanation.
I have a SSIS package which has an Event Handler (OnError, including some extra logging info) with Send Mail Task which is working just fine when the package fails
Database Mail is configured and Job Failure notifications are enabled in SQL Server Agent.
The idea behind that is because I use proxy to run the SSIS package and when the proxy is not working I need to receive email with error (which is now working). When the job starts it cannot go to SSIS OnError handler and if I'm not checking the jobs I will never know If the job is working or not.
Now when I have proxy problem I receive only one mail which is fine but when something in the SSIS package fails I receive 2 mails: one from SQL Server Agent notification, and another one from the OnError event handler from SSIS, which is something I'm trying to avoid.
I need only 1 email when an error occurs. Is it possible to prioritize it somehow and when the SQL job notification is sending mail another one from SSIS to be ignored?
I'm thinking to create one sample SSIS package only with one SQL Task and include it before all the SSIS steps just to check If the job is able to start. I don't know. I don't like the idea.
Do you have any ideas? Thanks.
Best regards.

What do you mean by the Proxy isn't working?
If you can define and test that, add a job step that does proxy test, and emails with send_dbmail as step 1. Keep the SSIS package as step 2 with it's inbuilt error notification, and disable the job notifications.

Related

What is the purpose of Alert inside a SQL agent job?

I am creating a new SQL agent job. I have already configured the job step and notifications so that the operator received an email upon failure.
I also see an option called 'Alerts' - I understand that this is a separate feature in SQL Agent. I would like to know - what is the purpose of Alert inside a SQL agent job?

SQL Server Agent Job stops SSIS Step with "unexpected error" and without any error informations

I am dealing with my problem on some Windows Server 2019 (Core) with one running SQL Server 2019 CU4 instance each.
What we try to do
We are currently building a data warehouse with distributed databases. The individual layers of the DWH are located on one database server each. The data exchange between the layers/servers takes place via SSIS ETLs, which use Linked Servers to reach the other layers and drag and drop data. Each layer also has its own SSIS service instance and executes the corresponding SSIS packets.
The SSIS packages are called by SQL Server Agent jobs. We have a job that executes the SSIS packets (#1), which in turn calls another job (#2) as the last step, which after a short wait time executes the calling job (#1). Thus, controlled by schedules, a loop is created and data is continuously transferred with ETLs.
I hope this was not too much unnecessary background
The error
Basically the job is running and there are numerous successful executions. However, we are observing interruptions at job #1 without helpful information regarding the error. This means that the job history log refers to the SSIS log, which again only contains an "unexpected termination". In the SSIS log, we only see behavior that indicates that the ETL packet active at that time stopped after validation. Depending on the log level, nothing is logged at all, not even the execution of single packages of the project. The package where this error occurs is different and not limited to a specific one.
What I have already tried
Re-create the jobs and SSIS Enviroments by hand (scripted before)
Using the 32Bit Runtime
Upgrade the SSIS project/package version to
2019
Increase the log level to "verbose"
Patching the SQL Server to CU4
Save ssis dump files (couldn't find them or they weren't created)
Search Windows and SQL Server Logfiles
Does anyone have some suggestions or some ideas how to become more error specific informations?
Thank you very much and take care :)
UPDATE We have an error message (OLE DB 0xC0202009 and 0X80004005)!
In order to exclude the use of environments as a cause, I manually set the parameters in the SSIS job step instead of overwriting them by selecting an environment.
Long story short: Today it turns out that the parameter for an OLE DB Connection String is not passed correctly.
The following is specified as a parameter in the job step:
However, the following connection string is specified in the context of the error message:
Please note that some arguments are added twice to the parameter (red).
What could have caused that?

Schedule a job on success of other in SQL Server 2014

I want to Schedule to run ETL_Job2 no Success of ETL_Job1 and on Success of ETL_Job2 has to start ETL_Job3.
Jobs are to be created in the SQL Server Agent and the SSIS packages associated with the respective job are from the separate solutions.
Appreciate any help on this.
One way is, you can maintain a table and at the end of the entire package process, the Execute SQL Task in SSIS Package should update the status of it. (Make sure that Error Handling should be done for that and in case of error it should update failure.)
And on another hand, another job should trigger itself to check the status of that table, once it gets status successful it can be started. All checking you can do in SSIS Package.
There is no built-in way to make a job run based on the success of another job.
The usual way to do this is to make all three "jobs" be different steps in the same job.

SSIS script task not working when scheduled

I cannot find a similar question. I have an SSIS package that contains a visual basic script task with the following line in it - msgbox("some text") . It runs fine from BIDS and manually executed from MSDB, but when I schedule it in SQL Server agent the package seems to fun fine until that point and completes. But the message box does not appear and none of the actually tasks after that run. The scheduled job reports complete and success. Can you point me to the right solution, I believe it would have something to do with the SSIS proxy account and its security but can't find anything. Does anyone know how to resolve this?
Here's a snapshot of my code. As you can see, I'm firing off lots of message boxes in an attempt to log what steps are working withing my package.
xworkbook = ExcelObject.Workbooks.Open("C:\xxx.csv")
xworksheet = DirectCast(xworkbook.Sheets(1), Excel.Worksheet)
MsgBox("csv")
xworksheet.Range("B:B").Replace(What:=",", Replacement:="")
MsgBox("replace 1")
xworksheet.Range("B:B").Replace(What:=".", Replacement:="")
MsgBox("replace 2")
xworkbook.SaveAs("C:\xxx.xlsx", FileFormat:=51) MsgBox("saved")
I believe that the reason it won't work is that when you run the SSIS task as a scheduled job it doesn't run in the context of your account but rather the service account for the SQL Server Agent and the message box won't show for you. The messagebox isn't valid for a non-interactive task.
#jpw hit the nail on the head for "The messagebox isn't valid for a non-interactive task."
To make it work you either need to strip your message boxes out of your code or inspect the value of the boolean Variable System::InteractiveMode
Code approximately
If CBool(Dts.Variables("System::InteractiveMode").Value) = True Then
....
End if
Assorted references
Microsoft SQL Server 2008 Integration Services Unleashed
How do I disable interactive message boxes from inside an SSIS package?
You overcome this by changing your process so that no user intervention is needed. There is no reason you should ever have a message box in SSIS except for debugging.

Where do I begin to learn about SQL Server alerts or notifications?

Just recently started having issues with an SQL Server Agent Job that contains an SSIS package to extract production data and summarize it into a separate reporting database.
I think that some of the Alerts/Notifications settings I tried playing with caused the problem as the job had been running to completion unattended for the previous two weeks.
So... Where's a good place to start reading up on SQL Agent Alerts and Notifications? I want to enable some sort of alert/notification so that I'm always informed:
That the job completes successfully (as a check to ensure that it's always executed), or
That the job ran into some sort of error, which should include enough info (such as error number) that I can diagnose the cause of the error
As always, any help will be greatly appreciated!
Books Online is probably a good place to start (or at least I like it and generally find it useful).
SQLMenace and bofe made some good points. Here's my additional two cents:
I'd recommend configuring Database Mail rather than SQL Mail (i.e. SMTP vs. MAPI, which I think is deprecated anyway). Once you get the mail profile configured, you'll have to also configure the SQL agent to use that mail profile (which is just a page of settings for the agent properties), or else your SSIS job notifications won't actually get sent, even though you can successfully send a test email from Management Studio.
I don't use alerts as often as job notifications, so the only tricky thing I can recall about them is that if you're raising an error and you want the alert to email you when that happens, you have to make sure that the raised error gets written to the log. I think that just boils down to "RAISERROR ... WITH LOG"; here's the BOL link for the syntax details.
In each step of the job click on advanced then from there you can log to a file or to a table, this will have all errorcodes and other things why the job failed
You should be able to see this also from the job history.
Right click on the job-->view history, click on the + sign to expand, the click on each step and it will be in the lower panel
To set up notifications you need to set up an operator and the in the job on the notification tab you pick it from the email dropdown
You'll want to have "When the job completes" marked in your notifications page on the job's properties.
Just go to that dropdown and switch it to job completion instead of failure (which is on the screenshot).
You'll also want to make sure that your server has e-mail configured. I think it's under SQL Surface Area Configuration for Features.

Resources