SSIS Conditional Split Lineage Error - sql-server

I'm trying to run an Excel table through an SSIS Package and 3 nodes in, it has a Conditional Split. I'm using a previously known working spreadsheet with some data added to it.
The error I'm getting specifically is:
Conditional Split.Inputs[Split Input].Columns[ColumnName] has lineage ID 147 that was not previously used.
I've tried a couple spreadsheets with no avail. I was getting ID 105 initially.
My specific questions are: What do the IDs correspond to? Where do I look to try troubleshooting them?
Some additional logs.
Output:
Error at Data Flow Task 1 [SSIS.Pipeline]: Conditional Split.Inputs[Conditional Split Input].Columns[ColumnName] has lineage ID 147 that was not previously used in the Data Flow task.
Error at Data Flow Task 1 [SSIS.Pipeline]: "Conditional Split" failed validation and returned validation status "VS_NEEDSNEWMETADATA".
Error at Data Flow Task 1 [SSIS.Pipeline]: One or more component failed validation.
Error at Data Flow Task 1: There were errors during task validation.

"Lineage ID is a property of the component or transformation used in the data flow task. It contains an integer value that will work as buffer pointer. Each column in the data flow task will be assigned a lineage ID." Read about lineage ID in this Microsoft TechNet article
LINEAGE ID Error implies that a Source metadata was changed, just re-validate source (connection and component) by double click on the the Conditional split and close it , then check the columns metadata (using the advanced editor). (Note that when double-clicking on a component that contains errors it will prompt to fix it)
Or you can try removing Conditional Split and adding it again (if previous solution doesn't works)

Right click Conditional Split -> Advanced Editor -> Input and Output Properties -> expend those columns, you will see each column has a LineageID.

I believe SSIS assigns unique identifiers (lineage IDs) to each column in each pipe connecting your components. SSIS gets confused when a component is expecting a lineage ID of x, but can't find it in the input pipe.
Generally, you try to find the offending pipe (in BIDS/SSDT, using #Wendy's method). Double-clicking the pipe or connected components will sometimes produce a dialog box offering the option to fix the issue. If not, then removing and recreating the pipe is your best chance.
Downstream components can be adversely affected when you change things upstream of them. Often, the only recourse when doing midstream modifications is to rebuild the entire downstream. SSIS is a bit brittle in this area.

Related

Is there a way to ignore mapping errors in SSIS?

I have a data flow in SSIS that's using an ODBC Source to a conditional split.
The source returns a dynamic set of columns dependent on availability of data in the source - the number of columns goes from 1 to 13.
In my conditional split I have it pointing at the source and feeding the data to a destination that fits its number of columns.
Example:
Condition 1 -> Map column 1 to column 1 and ignore the other 12 columns
Condition 2 -> Map column 1 and 2 to column 1 and 2 and ignore the other 11 columns
However, if the source only contains 1 column it fails on the second condition because "there are some mapping errors on this path"
I know that the count of columns will never exceed 13 which means I can set conditions for columns 1 - 13.
Is there any way that I can ignore the mapping error or force SSIS to stop at the last executable case in my conditional split?
I don't personally want to have to dive into a script component so if this can be done with conditional split I'd be relieved!
Any thoughts?
As Larnu indicates, the number of columns in a data flow is a design time artifact and cannot be changed at run-time.
But, you should be able to handle this with 12 data flows.
Execute SQL Task -> However your current ODBC source is generating a variable set of columns, determine how many are being returned. Assign this to an SSIS Variable #[User::ColumnCount]
Attach 12 output paths from the Execute SQL Task to custom Data Flow Tasks that account for the number of source columns.
Change the precedence constraint on each of the paths to be Constraint and Expression with expressions like #[User::ColumnCount]==1 ... ==13
The SSIS designer is going to try to validate metadata as you design the package. As will the execution engine when you run the package. Therefore, you'll need to set the Delay Validation property to True on each of the Data Flow Tasks after you finish designing them.
In fact, as I think about this more, you'd like be better served by a parent/child package paradigm here. Design a package per data flow task and then have the parent/controller package invoke them much as I described above. That should simplify the metadata validation challenges you'll experience trying to get this built.

SSIS throws an "DTS_E_PRIMEOUTPUTFAILED" error in SSIS Data Flow with Excel source

I developing an SSIS process that extracts data from Excel files and loads them into SQL Server DB.
I have separate data flows for each worksheet in the source file. The Excel file contains data in different formats (but can contain invalid data as well), so I'm using explicit type casting.
In case of dates, I'm using a cdate(f1) as f1 construction in the SQL statement (with number changing according to the column), in order to prevent SSIS from deciding on the date format on its own.
This usually works fine. However, in some cases it throws an error when I try to run the process and there's an illegal value in the data:
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The
PrimeOutput method on My_Excel_Source returned error code 0x80040E21.
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.
I don't have any other errors.
When I try to preview the result from within the Excel Source Editor window, I do get the data grid with data sample, as expected. When there's illegal data, the text is displayed - which is fine. In other data flows, the value of '1899-12-30' is returned and I can do whatever I want with it.
I've tried to define the data type for this column explicitly as DT_DATE, but I still get the error. I've compared all kinds of possible property settings with other data flows (that don't throw this error), and it all seems to be identical.
I've also tried to change the error handling behavior of the Excel Source component to "Ignore failure" instead of "Fail component" - no effect.
I should note, that there's no possible resource issue there. I'm dealing with just a handful of rows in each sheet (a few dozens, at most).
I expect the Excel Source component return the value of '1899-12-30' when the source cell contains an illegal value, rather than crashing the data flow.
Thanks,
David
If you want to let Excel control date parsing, I would try some SQL expression along the line
CASE
WHEN IsDate(f1) THEN CDate(f1)
ELSE NULL
END AS f1
So if the f1 parses as date, it casts it to Date, otherwise it returns NULL.
If you prefer, replace NULL with any sentinel value you might prefer, like CDate('1899-12-30').
Without IsDate guard, Excel OLEDB connector does what you told it to do - tries to cast the expression to date, and fails.
The functionality of testing per-cell whether the cast works and displaying text in case of failure is part of Excel application, not Excel OLEDB connector. So we need to emulate it here using the CASE expression above.

Not Creating the File when source has 0 rows

I have the below within the Data-flow area. The problem I'm experiencing is that even if the result is 0, it is still creating the file.
Can anyone see what I'm doing wrong here?
This is pretty much expected and known annoying behavior.
SSIS will create an empty flat file, even if unchecked: "column names in a first data row".
The workarounds are:
remove such file by a file system task if #RowCountWriteOff = 0 just after the execution of a dataflow.
as alternative, do not start a dataflow if expected number of rows in the source is 0:
Update 2019-02-11:
Issue I have is that I have 13 of these export to csv commands in the
data flow and they are costly queries
Then double querying a source to check a row-count ahead will be even more expensive and perhaps better to reuse a value of variable #RowCountWriteOff.
Initial design has 13 dataflows, adding 13 constraints and 13 filesystem tasks the main control flow will make package more complex and harder to maintain
Therefore, suggestion is to use a OnPostExecute event handler, so cleanup logic is isolated to some certain dataflow:
Update 1 - Adding more details based on OP comments
Based on your comment i will assume that you want to loop over many tables using SQL Commands, check if table contains row, if so then you should export rows to flat files, else you should ignore the tables. I will mention the steps that you need to achieve that and provide links that contains more details for each step.
First you should create a Foreach Loop container to loop over tables
You should add an Execute SQL Task with a count command SELECT COunt(*) FROM ....) and store the Resultset inside a variable
Add a Data Flow Task that import data from OLEDB Source to Flat File Destination.
After that you should add a precedence constraint with expression, to the Data Flow Task, with expression similar to #[User::RowCount] > 0
Also, it is good to check the links i provided because they contains a lot of useful informations and step by step guides.
Initial Answer
Preventing SSIS from creating empty flat files is a common issue that you can find a lot of references online, there are many workarounds suggested and many methods that may solves the issue:
Try to set the Data Flow Task Delay Validation property to True
Create another Data Flow Task within the package, which will be used only to count rows in the Source, if it is bigger than 0 then the precedence constraint should led to the other Data Flow Task
Add a File System Task after the Data Flow Task which delete the output file if RowCount is o, you should set the precedence constraint expression to ensure that.
References and helpful links
How to prevent SSIS package creating empty flat file at the destination
Prevent SSIS from creating an empty flat file
Eliminating Empty Output Files in SSIS
Prevent SSIS for creating an empty csv file at destination
Check for number of rows returned and do not create empty destination file
Set the Data Flow Task Delay Validation property to True

How can I make an SSIS Conditional Split task fail the process if rows are sent to default output

I have a Conditional Split task in my workflow which directs the data to one of three different destinations.
All my data should go to one of these three destinations. If there is data that does not conform to this rule it should cause the process to fail (i.e. nothing gets Loaded and the user is given an error).
Is there any way in SSIS to cause a Conditional Split task to fail the process if data is sent to its default output?
The most simple way to do that is to add a Script Component (Destination) after the Default Output. And Throw an exception from the Script Component. As example (VB.NET)
Throw new Exception("Condition are not met!")
Creating and Throwing Exceptions (C# Programming Guide)

How to prevent SSIS from truncating the last field of the last data row in a flat file?

I have an SSIS package thats unzips and loads a text file. It has been working great from the debugger, and from the various servers its been uploaded to on its way to our production environment.
My problem right now is this: A file was being loaded, everything was going great, but all of the sudden, on the very last data row (according to the error message) the last field was truncated. I assumed the file we receive was probably messed up, cracked it open, and everything is good there....
Its a | delimited file, no text qualifier, and {CR}{LF} as the row delimiter. Since the field with the truncation error is the last field in the row (and in this case the last field of the entire file), its delimiter is {CR}{LF} as opposed to |.
The file looks pristine and I've even loaded it into Excel with no issue and no complaints. I have run this file through my local machine running the package via the deugger in VS 2008, and it ran perfectly. Has anybody had any issues with behavior like this at all? I can't test it much in the environment that its crashing in, because it is our production environment and these are peak hours.... so any advice is GREATLY appreciated.
Error message:
Description: Data conversion failed. The data conversion for column "ACD_Flag" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.". End Error Error: 2013-02-01 01:32:06.32 Code: 0xC020902A Source: Load ACD file into Table HDS Flat File 1 [9] Description: The "output column "ACD_Flag" (1040)" failed because truncation occurred, and the truncation row disposition on "output column "ACD_Flag" (1040)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component. End Error Error: 2013-02-01 01:32:06.32 Code: 0xC0202092 Source: Load ACD file into Table [9] Description: An error occurred while processing file "MY FLAT FILE" on data row 737541.
737541 is the last row in the file.
Update: originally I had the row delimiter {CR}, but I have updated that to {CR}{LF} to attempt to fix this issue... although to no avail.
Update:
I am able to recreate the error message that you have added to your question. The error happens when you have more column delimiters in the line than what you have defined in the flat file connection manager.
Here is a simple example to illustrate it. I created a simple file as shown below.
I created a package and configured the flat file connection manager with below shown settings.
I configured the package with a data flow task to read the file and populate the data to a database table. When I executed the package, it failed.
Clicked the Execution Results tab on the BIDS. It displays the same message that you have posted in your question.
[Flat File Source [44]] Error: Data conversion failed. The data conversion for column "Column 1" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
[Flat File Source [44]] Error: The "output column "Column 1" (128)" failed because truncation occurred, and the truncation row disposition on "output column "Column 1" (128)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
[Flat File Source [44]] Error: An error occurred while processing file "C:\temp\FlatFile.txt" on data row 2.
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Flat File Source" (44) returned error code 0xC0202092. 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.
Hope it helps to identify your problem.
Previous answer:
I think that the value in the last field on the last row of your file probably exceeded the value of OutputColumnWidth property of the last column on the Flat File Connection Manager.
Right-click the Flat File Connection Manager on your SSIS package. Click Advanced tab page on the Flat File Connection Manager Editor. Click on the last column and check the value on the OutputColumnWidth property.
Now, verify the length of data on the last field of the last row in the file that is causing your package to fail.
If that is cause of the problem, here are two possible options to fix this:
Increase the OutputColumnWidth property on the last column to an appropriate length that meets your requirements.
If you do not care about truncation warnings, you can change the truncation error output on the last column of the Flat File Source Editor. Double-click the Flat File Source Editor, click Error Output. Change the Truncation column value to either Ignore failure or Redirect row. I prefer Redirect row because it gives the ability to track data issues in the incoming file by redirecting the invalid to a separate table and take necessary actions to fix the data.
Hope that gives you an idea to resolve your problem.
So I've come up with an answer. The other answers are extremely well thought out and good, but I solved this using a slightly different technique.
I had all but eliminated the actual possibility of truncation because once I looked into the data in the flat file, it just didn't make sense... truncation could definitely NOT be occuring. So I decided to focus the second half of the error message: or one or more characters had no match in the target code page
After some intense Googleing I found a few sites like this one: http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/6d4eb033-2c45-47e4-9e29-f20214122dd3/
Basically the idea is that if you know truncation isn't happening, you have characters without a code page match, so a switch from 1252 ANSI Latin I to 65001 UTF-8 should make a difference.
Since this has been moved to production, and the production environment is the only environment having this issue I wanted to make 100% sure I had the correct fix in, so I made one more change. I had no text qualifier, but SSIS still keeps the default Text_Qualified property for each column in the Flat File Connection Manager to TRUE. I set ALL of them to false (not just the column in question). So now the package doesn't see it needs a qualifier, then go to the qualifier and see <none> and then not look for a qualifier... it just flat out doesn't use a qualifier period.
Between these two changes the package finally ran successfully. Since both changes were done in the same release, and I've only received this error in production and I can't afford to switch different things back and forth for experimental purposes, I can't speak to which change finally did it, but I can tell you those were the only two changes I made.
One thing to note: the production machine running this package is: 10.50.1617 and my machine I am developing on (and most of the machines I am testing on) are: 10.50.4000. I've raised this as a possible issue with our Ops DBA and hopefully we'll get everything consistent.
Hopefully this will help anybody else who has a similar issue. If anybody would like additional information or details (I feel as if I've covered everything) please just comment here and let me know. I will gladly update this to make it more helpfull for anybody coming along in the future.
It only happens on the one server? And you aren't using a test qualifier? We have had this happen before. This is what fixed it.
Go to that server and open the xml file. Search forTextQualifier and see if it says:
<DTS:Property DTS:Name="TextQualifier" xml:space="preserve"><none></DTS:Property>
If it doesn't make it say that.
I had the exact same error. My source text file contained unicode characters and I solved it by saving the text file using unicode encoding (instead of the default utf-8 encoding) and checking the Unicode checkbox in the Data Source dialog.
Just follow these simple steps.
1. Right-click the OLE DB source or destination object, and then click Show Advanced
Editor….
2. On the Advanced Editor screen, click the Component Properties page.
3. Set AlwaysUseDefaultCodePage to True.
4.Click OK.
5.Clicking OK saves the settings for use with the current OLE DB source or destination object within the SSIS package.
I know this is a whole year later, but when I opened the flat file connection manager, for the text qualifier it had "_x003C_none_x003E_". I replace the "_x003C_none_x003E_" hex code garbage and put arrows like it should be, "<" none ">" (the editor is removing the arrows), and it stopped dropping the last row of the file.
Below steps may help you in solving your problem.
Go to show advance editor by right clicking on Source.
2.Click on Component properties.
And set AlwaysUseDefaultCodePage to TRUE.
And save he changes.

Resources