SSIS package gives error after deployment SQL Server 2012 - sql-server

I created a package in Visual Studio 2015. It works fine.
Basically I am using a script task that generates Excel spreadsheet and sends it to different users.
After I deploy the package to SQL Server 2012 and then try to execute it from there - I get an error without any further details.
I also run select * from internal.packages from SSISDB to make sure package_format_version is 6, which is what should be for SQL Server 2012.
What could be the problem?

This necessarily isn't an answer on how to fix the issue, but it's an answer on how you can modify your script task to get a better error message then "Script Task Failure: Exception has been thrown..."
We'll always wrap our script tasks in a try-catch and then raise the exception message back out of the script task:
public void Main()
{
try
{
//Your code here
Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception ex)
{
Dts.Events.FireError(-1, "", ex.Message, String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
It's always a challenge, especially with a deployed SSIS package, when it errors on a scrip task you don't necessarily get a clear indication as to why it's failing and you get a cryptic error message. The above code will capture what threw the exception and bubble back out to integration services what that was.

You may want to make sure that the "Microsoft Access Database Engine 2010 Redistributable" driver is installed on the SSIS server. You can get it here.

Related

ODBC Connection on SSIS package fails only when it goes through a loop

We've been recently trying to migrate out of SQL Server 2016 to SQL Server 2019 on our servers, that includes upgrading all the SSIS Packages we have on our catalog.
The migration wizard had no issues and migrated all packages with no errors, and on the surface everything seems OK. Even tried a test run on Visual Studio, and everything worked. But once we deployed all the packages on the catalog and tried a run via there, we started getting the following error:
none
Error: 0xC0014020 at Load ODI_PaymentDevice, ODBC Source [14]: SQLSTATE: HY010, Message: [Microsoft][ODBC Driver Manager] Function sequence error;
Error: 0xC0209029 at Load ODI_PaymentDevice, ODBC Source [14]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "ODBC Source.Outputs[ODBC Source Output]" failed because error code 0xC020F450 occurred, and the error row disposition on "ODBC Source" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
Error: 0xC0047038 at Load ODI_PaymentDevice, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on ODBC Source returned error code 0xC0209029. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.
This is only on the packages that have an connection with Hive, using the ODBC Connector on SSIS, and then ODBC Data Source on a Data Flow
Based on the error code, it could be narrowed down to the ODBC Connection we have to our Hadoop-Hive cluster, the connection for sure works as we tested it on the Windows' ODBC Sources tool, and works as well on Visual Studio. We've researched a lot about this error and the different soulutions to this. So we tried a lot of different things.
Deleting the data source and then creating a new one (To update metadata)
Running in 32 Bit mode
Updating Microsoft's Hive ODBC driver
Switching to a different vendor's driver (CDATA)
Switching to an ADO.NET connection instead
Played around with the driver's configuration, almost all combinations possible
After trying all of this to no avail, we tried again on Visual Studio, and to our surprise, it also started to fail there too.
After trying a few different things, we could reproduce again the conditions in which the package worked, and it is the strangest thing, we could not find anyone with a similar issue on the internet so far.
So, as stated before, the connection works, and the package itself also does, BUT, we have a For Each Loop Container, that iterates through dates, to load data for the last X dates we have, so if there is any kind of loop container (For Each loop, for example) that contains a query against our ODBC source, it fails on the second loop around 100% of the time.
So that is the reason it worked on Visual Studio, because it only ran once (had only one date to process as test), but when deployed, it had to fetch real data, with a bunch of different dates.
To confirm that this is indeed the issue, deployed the package, and updated the table with dates to load, to have only available 1 day. And the package ran through. Also ruling out any parameter issue on the deployment/server/catalog.
After this discovery we tried a few different things:
Passing NULL on every column to see if there is some issues with metadata between loops
Also activated LOG_TRACE on the Hive ODBC driver, to have a very detailed log of what is happening, we see the query going out for the second loop on the log, and it also appears on TEZ (our Hive execution engine) but very briefly, only fractions of a second. And then it cancels itself, so the query is arriving the cluster, but somehow SSIS drops the connection by itself.
As mentioned before, we couldn't find anything like this before, and we cannot think of any other options to solve the issue without having to directly change the packages or not upgrading to 2019 at all, which is not ideal knowing that it is already outside of the mainstream support cycle.
Anyone has an idea how this might be solved or what may be causing this issue?
I have faced a very similar issue (if not the same) with the SSIS ODBC Source Component inside a For Loop for transferring records in batches from a remote PostgreSQL server to a database on MS SQL Server 2019. My Visual Studio is 2019 and the MS SQL Server is 2019 as well. The very weird thing was that the package was running as expected in VS (Debugging and Without Debugging), then it was working quite well through the SQL Job Agent of the SQL Server installed on my machine, but when deployed on the production SQL Server (the same version and psqlodbc driver installed there) the package was running successfully for the first iteration of the For Loop component and then unexpectedly was crashing, showing in the logs the same errors you have posted above: SQLSTATE: HY010, Message: [Microsoft][ODBC Driver Manager] Function sequence error;.....etc. After many hours spent on this without any success, I finally fixed it and now it is working like a charm; hence decided to share how I figured that out, so hopefully it may be of help to you or anyone facing that challenge.
What I found out is that for some reason the problem was happening inside the ODBC Source Component, but could not do much as it is like a black box. I fixed the problem by switching to a Script Source Component, so that I took control over the connection in the C# code. Here below, I also share the code:
#region Namespaces
using System;
using System.Data;
using System.Data.Odbc;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
#endregion
...........
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
...........
public override void CreateNewOutputRows()
{
string connectionString = this.Connections.PostgreSQLODBCConn.ConnectionString;
using (OdbcConnection conn = new OdbcConnection(connectionString))
{
using (OdbcCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT * FROM fn_transfer_records(500000);";
cmd.CommandType = CommandType.Text;
DataTable dt = new DataTable();
conn.Open();
using (OdbcDataAdapter adapter = new OdbcDataAdapter(cmd))
{
adapter.Fill(dt);
foreach (DataRow row in dt.Rows)
{
Output0Buffer.AddRow();
Output0Buffer.col1 = (Int32)row["col1"];
Output0Buffer.col2= (double)row["col2"];
}
}
}
}
}
}
The PostgreSQLODBCConn used in the code above is the name of the Connection added to the connections collection of the Script Component added through the visual editor of the component when you double click on it.
Hope this would be of help...
Ensure your SQL Server Target version is set to SQL Server 2019. This can be found from the Project properties. This error is typical of a mismatched target server, as the issue is only present during deployment, and not during development.

Deployed package execution in SSISDB shows success but write action never happened

I simplified the issue to a simple write action in C# script task, writing current time stamp into a text file located on the same machine in C:\test\ granted full control to Everyone. The environment is SQL Server 2016, Visual Studio 2015, and Windows Server 2016.
If create a SQL Server Agent job from file system, it updates the text file as expected. If deploy the package into SSISDB and execute, the execution report shows all green and success while the write action never happened. And I was not able to find any clue in system logs.
I will be very grateful to inputs on:
1) What might be wrong in this simple-write test; and
2) How to get more useful log information about this error and possibly other issues.
FYI, Related issues resolved before this post:
SSIS deployed package fails to map drive tag to network shared folder
Code in the simple-write script task.
public void Main()
{
Dts.TaskResult = (int)ScriptResults.Failure;
try
{
// TODO: Add your code here
using (var writer = new StreamWriter("C:\\test\\simple-write.txt", true, Encoding.Unicode))
{
writer.WriteLine(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffffK"));
writer.Flush();
}
Dts.TaskResult = (int)ScriptResults.Success;
}catch(Exception ex)
{
Dts.Events.FireError(0, "Simple-Write-Test", ex.ToString(), String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
I got the answer on the following link:
https://social.msdn.microsoft.com/Forums/en-US/6c34874c-03a2-4926-8989-b977c1ec1866/deployed-package-execution-in-ssisdb-shows-success-but-write-action-never-happened?forum=sqlintegrationservices
It seems to be a compatibility issue between the latest version of Management Studio (2017 suite) and SQL Server 2016 database. The script task in the deployed package was silently ignored.

SSIS - Execute SQL Task - Foreach Loop Container

I try new project SSIS and i have an error
Exception deserializing the package "The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored.". This occurs when CPackage::LoadFromXML fails.
". (Microsoft.DataTransformationServices.VsIntegration)
and Foreach Container no show variables load from Executed SQL task
[SQL Server 2014, Visual studio 2015]
Please help me!
Executed SQL Task - configuration
Foreach Loop Container
I sloved
Click properties solution and change target sql server with version running in your system.

How to simulate a data exception with localdb

I'm using a LocalDB database with EntityFramework on an ASP.NET MVC project.
How can I simulate a connection failure to test the following try...catch block?
try
{
if (ModelState.IsValid)
{
db.Entry(course).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
}
catch (DataException)
{
ModelState.AddModelError("", "Unable to save changes.");
}
I've tried trying to take the database offline in SQL management studio, but it just hangs. I can't stop the SQL service as LocalDB doesn't run as a service.
Have you tried giving it a non-existing name of LocalDB instance? Just put this in your connection string for this test:
Server=(localdb)\missing_instance`
(if you embed this connection string in code don't forget to escape the \ character :-))
connectionString="Server=(localdb)\\missing_instance;..."
You can stop a LocalDB instance even though it doesn't run as a service, you can use the SQLLocalDB.exe tool to do this:
SqlLocalDB Utility

How to ping from within an SSIS package?

I'm trying to verify a connection through a firewall, and we are very limited in the access allowed. Ultimately, data will be loaded from an Access database on another server to our SQL Server database using an SSIS package. I can ping that source server from my computer and get a reply -- I want to put that in our SSIS package and see if the destination SQL Server can get a ping reponse.
Right now, the OLE DB source connection fails from both my computer and the server, ping works directly from my computer, and I don't know if it will work from the server or not. SSIS is the only thing I can put and run on the server, and it also what we plan on using for getting data from this other source.
Is there a fairly simple way to use a SSIS package to ping a specific address? I probably don't even need to know anything more than whether it fails or works.
I cannot use sys.sp_comdshell because that is turned off as part of our security configuration for our sql server. I cannot remote to the server and use ping directly.
You could add a Script Task to your Control Flow with some code that does the ping for you. The System.Net.NetworkInformation namespace in .NET 2.0 and up contains a Ping class that can do the work for you. I suspect it might look something like this:
public void Main()
{
using (Ping ping = new Ping())
{
try
{
PingReply reply = ping.Send(url, 100);
if (reply.Status == IPStatus.Success)
{
Dts.TaskResult = (int)ScriptResults.Success;
}
else
{
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
catch
{
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
}

Resources