Why am I getting 0 rows processed in SSIS? - sql-server

I am creating a SSIS package using MS Visual Studio 2012 Shell with .Net framework of 4.6.01055. The SSIS package has a Data Flow task with Flat File Source, Data Source Row count, Final Data Set count and OleDb destination tasks. It connects to a SQL Database and I have checked to see that my connection has been tested.
I have a flatfile connection manager which picks up a text file. On the Preview section it only shows the header columns in the flat file connection manager editor. The error message is only at warning level with the following message: [Flat File Source [10]] Warning: The end of the data file was reached while reading header rows. Make sure the header row delimiter and the number of header rows to skip are correct. The file itself has a total of 19 rows with the first being the header row.
I have spaces in the header names of the origin file. So on that file I edited to have no spaces on the final column. That did not cure the issue. The last column is a date but I am designating as OutputColumnWidth of 50 and datatype as string[DT_STR]. I have the Row delimiter as {CR}{LF}. I have the column delimiter as {|}. When run the package file name does not change.
In the General section of the editor under locale = English; Unicode is not checked; Code Page = 1252 (ANSI-Latin1); Format = Delimited; Text qualifier = none; Header row delimeter = {CR}{LF} (I have tried just CR or LF as well); Header rows to skip=0 (I have tried 1 as well since there is only one header row); and I have checked Column Names if the first data row.
Why am I not getting data in my preview section? And why is it thinking I only have a header?

It seems to me that your text file does not have a matching EOL marker, and so SSIS never splits the lines (and treats the file as just having one big header).
Try opening the file in a text editor that lets you see the EOL marker. I know that NotePad++ can do this for you.
NotePad++ will also let you change the file's encoding as well, in case that is also a problem.
NB: The problem could also be that you are not specifying a correct column delimiter. If the delimiter you specify in SSIS doesn't match characters in the file, then SSIS will also think that you have a single header row where everything is in the first column.

Just to add to the other answer:
I had the same problem, when i opened the file in notepad, it became clear that there was a trailing empty line at the bottom.
So: make sure the last line of the file actually contains text.

Related

SSIS Ignore Blank Lines

I get the following SSIS error message when my source file has blank lines at the end of the file. I don't care about the blank lines as they don't affect the overall goal of pumping data from a text file to a database table. I'd like to ignore this message or, if its easier, configure SSIS to ignore blanks.
<DTS:Column DTS:ID="96" DTS:IdentificationString="Flat File Source.Outputs[Flat File Source Error Output].Columns[Flat File Source Error Output Column]"/>
I found a similar question below, but the solution isn't an SSIS one, its one that preprocesses the text files which would be my least favorite solution.
SSIS Import Multiple Files Ignore blank lines
If you want to exclude records with blank values you can use the Conditional Split. Add it between you source file and your destination.
The expression can be like below :
ISNULL(Col1) && ISNULL(Col2) && ISNULL(Col3) ...
Name the output as Remove Blank Lines. When connecting your Conditional Split to your destination, SSIS will ask you what output the split component that needs to be returned. In this case chose the Conditional Split Default Output to get the entire records without the blank values.
You can enable Data Viewer before and after the conditional split to see the filtered output.

SSIS Export OLEDB Source to a Flat File with UTF-8

I am trying to export an OLEDB source (from a stored procedure) to an UTF-8 flat file, but am getting the following error:
[Flat File Destination [2]]
Error: Data conversion failed. The data conversion for column "name" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
The name column is defined in the stored procedure as nvarchar(30).
In the advanced editor of the OLEDB source, I have the AlwaysUseDefaultCodePage set to true and the DefaultCodePage set to 65001.
In the advanced editor for the flat file for the External Columns and Input columns, the Data Type is Unicode string [DT-WSTR] with a length of 30.
The connection manager for the flat file has the Unicode checkbox un-checked and the Code page is: 65001 (UTF-8).
I am stumped right now and any help would be appreciated.
Thanks,
David
EDIT:
I added a redirect of errors and truncations to a flat file destination but nothing was sent to the file.
Also, when I have a data viewer on the OLE DB source it comes up with all the records.
The data viewer for the Destination also shows all the records. The length of the name in both viewers is 30 characters (from Excel).
I gave up on getting the data flow to work and coded a C# script task instead.
I changed the output of my data flow to produce a Unicode file by checking the Unicode check box in the flat file connection manager.
I then have the new C# script read the Unicode file one line at a time and output the line to another flat file using Encoding.UTF8 adding a new line character at the end of the line variable.
After the new file is created, I delete the input file and rename the new file to be the same path and name as the original input file. This is also done in the C# script.

Flat file connection manager carriage return/line feed discrepancy

I'm upgrading from SQL Server 2008R2 to 2017, and making the same jump with SSIS. There are a number of flat file imports that are picking up files that have carriage return/line feeds ({CR}{LF}) embedded within a column in the row.
The 2008R2 flat file connection manager ignores the embedded {CR}{LF}s that are within a row, but the flat file connection manager in 2017 is treating each {CR}{LF} as a new line. It's the same in an upgraded connection manager or a brand new one that I make from scratch.
In both versions, the connection managers have the same specs:
General Tab
Locale: English (United States)
Unicode: No
Code page: 1252 (ANSI-Latin I)
Format: Delimited
Text qualifier: <none>
Header row delimiter: {CR}{LF}
Header rows to skip: 0
Column names in the first data row: Check
Columns Tab
Row delimiter: {CR}{LF}
Column delimiter: Vertical Bar{|}
The not particularly complicated text file I'm testing with:
row_id|row_data|empty_column|created_by|one_more_field{CR}{LF}
1|random test data||ebrandt|{CR}{LF}
2|Data field with a carriage return{CR}{LF}
and a line feed embedded in it.||ebrandt|
I pasted on the line terminators, just to show that they're there.
On the Columns tab, the Preview window in BIDS 2008R2 shows two rows:
But in 2017, exactly the same file gets broken into three rows:
There isn't bandwidth in this project to rework all the file imports.
Is there a setting that got changed between versions that I can change back? Or is there another trick to this that I'm missing?
Edit: In response to a comment that's been deleted, I would specify a text qualifier if I could, but the files I'm getting don't have any.
In the Flat File Connection Manager you need to set the AlwaysCheckForRowDelimiters property to False.
Your file will then be parsed as before.
This was a change made in 2012 to change behaviour to the following.
By default, the Flat File connection manager always checks for a row
delimiter in unquoted data, and starts a new row when a row delimiter
is found. This enables the connection manager to correctly parse files
with rows that are missing column fields.
See this link for more about it.

SAP Data Services .csv data file load from Excel with special characters

I am trying to load data from an Excel .csv file to a flat file format to use as a datasource in a Data Services job data flow which then transfers the data to an SQL-Server (2012) database table.
I consistently lose 1 in 6 records.
I have tried various parameter values in the file format definition and settled on setting Adaptable file scheme to "Yes", file type "delimited", column delimeter "comma", row delimeter {windows new line}, Text delimeter ", language eng(English) and all else as defaults.
I have also set "write errors to file" to "yes" but it just creates an empty error file (I expected the 6,000 odd unloaded rows to be in here).
If we strip out three of the columns containing special characters (visible in XL) it loads a treat so I think these characters are the problem.
The thing is, we need the data in those columns and unfortunately, this .csv file is as good a data source as we are likely to get and it is always likely to contain special characters in these three columns so we need to be able to read it in if possible.
Should I try to specifically strip the columns in the Query source component of the dataflow? Am I missing a data-cleansing trick in the query or file format definition?
OK so didn't get the answer I was looking for but did get it to work by setting the "Row within Text String" parameter to "Row delimiter".

Strange/Inconsistent SSIS row import error

I'm importing a csv non-unicode file using SSIS into SQL Server. I get the error "Text was truncated or one or more characters had no match in the target code page". It fails in column 0 on row 70962, which has data just like every other row; the data in the first column is no longer than the data in rows above it.
My column 0 is defined in the flat file connection, and in the database, as 255 wide. The data in row 70692 (and most other rows) is 17 characters.
The strange thing is, if I remove a row above row 70962 in the file, even the first row, and save the csv file, then the import runs fine. If I replace that removed row, and run the import, it fails again.
So I'm not even sure how to identify what the issue is.
If I create a new flat file connection that is a single column, I can import the whole file into a single-column table. But as soon as I add the first column delimiter (i.e. second column), then it fails on that same row.
At the moment I'm just short of idea as to how to debug this further.
You already gave the answer in your question ;)
if I remove a row above row 70962 in the file, even the first row, and
save the csv file, then the import runs fine.
You have a broken delimiter somewhere in the file. when you remove any data before the offending line the mismatch of delimiters is probably not properly handled but simply left open until the very end of the file after which the program handles it for you.
Check the row and column delimiters of the row above the one you mentioned and that very row.

Resources