<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BI Monkey &#187; Flat File</title>
	<atom:link href="http://www.bimonkey.com/tag/flat-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bimonkey.com</link>
	<description>James Beresford on Microsoft BI and Consulting in Sydney, Australia</description>
	<lastBuildDate>Mon, 23 Jan 2012 22:01:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Convert Text Stream to String</title>
		<link>http://www.bimonkey.com/2010/09/convert-text-stream-to-string/</link>
		<comments>http://www.bimonkey.com/2010/09/convert-text-stream-to-string/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 00:59:17 +0000</pubDate>
		<dc:creator>BI Monkey</dc:creator>
				<category><![CDATA[Microsoft BI]]></category>
		<category><![CDATA[Flat File]]></category>
		<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Text Stream]]></category>

		<guid isPermaLink="false">http://www.bimonkey.com/?p=809</guid>
		<description><![CDATA[One of the ongoing challenges with SSIS is its difficulty in handling complex or damaged text files. One approach to dealing with such files is to bring them all in as one wide text column and then split them using code. Sometimes, the file is too wide for that approach, so below is an extension of [...]]]></description>
			<content:encoded><![CDATA[<p>One of the ongoing challenges with SSIS is its difficulty in handling complex or damaged text files. One approach to dealing with such files is to <a title="Importing the entire contents of the file into a single column, then parsing it in a script task" href="http://www.bimonkey.com/2009/06/flat-file-source-error-the-column-delimiter-for-column-columnname-was-not-found/">bring them all in as one wide text column and then split them using code</a>. Sometimes, the file is too wide for that approach, so below is an extension of that method where you import the column as a text stream (DT_TEXT, or Unicode DT_NTEXT) and then split the text stream in a script transformation:</p>
<blockquote><p>        <span style="color: #008000;">&#8216; Declare variables</span><br />
        <span style="color: #0000ff;">Dim </span>TextStream <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">Byte</span>()            <span style="color: #008000;">&#8216; To hold Text Stream</span><br />
        <span style="color: #0000ff;">Dim</span> TextStreamAsString <span style="color: #0000ff;">As String</span>  <span style="color: #008000;">  &#8216; To Hold Text Stream converted to String</span><br />
        <span style="color: #0000ff;">Dim</span> StringArray() <span style="color: #0000ff;">As String</span>       <span style="color: #008000;">  &#8216; To contain split Text Stream</span></p>
<p><strong>       <span style="color: #008000;"> &#8216; Load Text Stream into variable</span><br />
        TextStream = Row.TextStreamColumn.GetBlobData(0, <span style="color: #0000ff;">CInt</span>(Row.Column0.Length))</strong></p>
<p><strong>     <span style="color: #008000;">   &#8216; Convert Text Stream to string</span><br />
        TextStreamAsString = System.Text.Encoding.ASCII.GetString(TextStream)</strong></p>
<p>        <span style="color: #008000;">&#8216; Split string into array and output</span><br />
        StringArray = TextStreamAsString.Split(<span style="color: #800000;">&#8220;#&#8221;</span>)        </p>
<p>        Row.Column1 = StringArray(1).ToString<br />
        Row.Column2 = StringArray(2).ToString<br />
        Row.Column3 = StringArray(3).ToString  </p></blockquote>
<p>An important thing to note is that in the step where the Text Stream is converted to a string, the Encoding will depend on the type of text stream you are bringing in &#8211; Unicode files will need &#8221;Unicode&#8221; instead of &#8220;ASCII&#8221;. Also I have used a hash (&#8220;#&#8221;) as the column delimiter but that value will vary depending on what type of file you are bringing in.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bimonkey.com/2010/09/convert-text-stream-to-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flat Files with too many Delimiters</title>
		<link>http://www.bimonkey.com/2009/09/flat-files-with-too-many-delimiters/</link>
		<comments>http://www.bimonkey.com/2009/09/flat-files-with-too-many-delimiters/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 03:38:44 +0000</pubDate>
		<dc:creator>BI Monkey</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Flat File]]></category>

		<guid isPermaLink="false">http://www.bimonkey.com/?p=593</guid>
		<description><![CDATA[It is not uncommon for flat file sources to have delimiters where they shouldn&#8217;t be &#8211; extra commas in address fields is a particularly common problem, for example. These don&#8217;t necessarily cause the import to fail &#8211; especially if the data is not being imported is not being done so in a strongly typed manner. [...]]]></description>
			<content:encoded><![CDATA[<p>It is not uncommon for flat file sources to have delimiters where they shouldn&#8217;t be &#8211; extra commas in address fields is a particularly common problem, for example. These don&#8217;t necessarily cause the import to fail &#8211; especially if the data is not being imported is not being done so in a strongly typed manner.</p>
<p>To understand what happens, you need to understand how SSIS Flat File sources handle delimited files. Unlike Access or Excel, it doesn&#8217;t carve up the rows based on it finding a delimiter and creating a column. In an SSIS source the number of columns is predefined. So imagine I had a Flat File Connection manager configured as below:</p>
<div class="wp-caption alignnone" style="width: 311px"><img title="Flat File Connection Manager" src="http://www.bimonkey.com/uploads/ssis/extradelimiter1.jpg" alt="b" width="301" height="118" /><p class="wp-caption-text">Fig 1: Flat File Connection Manager</p></div>
<p>How it reads in a row in a file is as follows:</p>
<ol>
<li>Scan until reaches 1st comma &#8211; Put found data in &#8220;RowID&#8221;</li>
<li>Continue scan until reaches 2nd comma &#8211; Put found data in &#8220;MonkeyFood&#8221;</li>
<li>Continue scan until reaches 3rd comma &#8211; Put found data in &#8220;Motivation Factor&#8221;</li>
<li>Continue scan until reaches Carriage Return / Line Feed &#8211; Put found data in &#8220;Cost&#8221;</li>
</ol>
<p>So the outcome is that if you happen to have more than 3 commas in your row, anything after the 3rd comma but before the Carriage Return / Line Feed ends up in the 4th column. So if you look at my example below, where the 2nd row of the text file has gone a little comma crazy and has 6 commas in it:</p>
<blockquote><p>RowID,Monkey Food,Motivation Factor,Cost<br />
1,Peanuts,1,10<br />
<strong><span style="color: #ff0000;">2,C,a,s,hews,2,15</span></strong><br />
3,Tea,3,24<br />
4,Coffee,7,81</p></blockquote>
<p>The end result of pumping it through the connection manager as defined in Fig 1 is this:</p>
<div class="wp-caption alignnone" style="width: 398px"><img title="Output from corrupted file" src="http://www.bimonkey.com/uploads/ssis/extradelimiter2.jpg" alt="b" width="388" height="202" /><p class="wp-caption-text">Fig 2: Output from corrupted file</p></div>
<p>Note how everything after the 3rd comma has ended up in the final column, because after reaching the 3rd column it has scanned across for the Carriage return / Line Feed to define the final column <span style="text-decoration: underline;">ignoring any further commas</span>.</p>
<p>There is a <a title="Sample package, Right click &amp; save as" href="http://www.bimonkey.com/uploads/ssis/Flat Files with Extra Delimiters 2005.zip">sample package here</a> demonstrating the above example.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bimonkey.com/2009/09/flat-files-with-too-many-delimiters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flat File Sources and the Decimal Data Type</title>
		<link>http://www.bimonkey.com/2009/07/flat-file-sources-and-the-decimal-data-type/</link>
		<comments>http://www.bimonkey.com/2009/07/flat-file-sources-and-the-decimal-data-type/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 00:55:46 +0000</pubDate>
		<dc:creator>BI Monkey</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Data Types]]></category>
		<category><![CDATA[Flat File]]></category>

		<guid isPermaLink="false">http://www.bimonkey.com/?p=498</guid>
		<description><![CDATA[Question: What Data Type should you use for importing a column in Flat File containing Decimal data? Answer: numeric [DT_NUMERIC] You cannot use the decimal [DT_DECIMAL] type, because in the Advanced Editor of the Flat File connection, the decimal type for some reason only allows you to set the Scale (the number of digits after [...]]]></description>
			<content:encoded><![CDATA[<p>Question: What Data Type should you use for importing a column in Flat File containing <strong>Decimal</strong> data?</p>
<p>Answer: <strong>numeric [DT_NUMERIC]</strong></p>
<p>You cannot use the <strong>decimal</strong> [DT_DECIMAL] type, because in the Advanced Editor of the Flat File connection, the <strong>decimal</strong> type for some reason only allows you to set the Scale (the number of digits after the decimal point) &#8211; the Precision is greyed out (precision is the total number of digits). The <strong>numeric</strong> data type allows the setting of both values.</p>
<p>Fortunately the SSIS <strong>numeric</strong> type maps to SQL Server <strong>decimal</strong> columns without complaint, so you don&#8217;t have to add a <a title="SQL Server SSIS Data Conversion Transformation | BI Monkey" href="http://www.bimonkey.com/2009/06/the-data-conversion-transformation/">Data Conversion </a>to change numeric to decimal before using it. I have <a title="SSIS Flat File Connection Manager: Cannot set precision for Decimal columns" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=477262">raised a bug on Connect</a> &#8211; please vote it up if you consider this worth fixing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bimonkey.com/2009/07/flat-file-sources-and-the-decimal-data-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flat File Source Error: The column delimiter for column [ColumnName] was not found</title>
		<link>http://www.bimonkey.com/2009/06/flat-file-source-error-the-column-delimiter-for-column-columnname-was-not-found/</link>
		<comments>http://www.bimonkey.com/2009/06/flat-file-source-error-the-column-delimiter-for-column-columnname-was-not-found/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 11:55:06 +0000</pubDate>
		<dc:creator>BI Monkey</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Flat File]]></category>

		<guid isPermaLink="false">http://www.bimonkey.com/?p=400</guid>
		<description><![CDATA[Today when trying to import an Oracle sourced delimited file, this error cropped up: [Flat File Source [1]] Error: The column delimiter for column &#8220;ColumnName&#8221; was not found. [Flat File Source [1]] Error: An error occurred while processing file &#8220;MyTextFile&#8221; on data row [nnnn]. Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on component &#8220;Flat [...]]]></description>
			<content:encoded><![CDATA[<p>Today when trying to import an Oracle sourced delimited file, this error cropped up:</p>
<p><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves /> <w:TrackFormatting /> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF /> <w:LidThemeOther>EN-AU</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> <w:SplitPgBreakAndParaMark /> <w:DontVertAlignCellWithSp /> <w:DontBreakConstrainedForcedTables /> <w:DontVertAlignInTxbx /> <w:Word11KerningPairs /> <w:CachedColBalance /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math" /> <m:brkBin m:val="before" /> <m:brkBinSub m:val="&#45;-" /> <m:smallFrac m:val="off" /> <m:dispDef /> <m:lMargin m:val="0" /> <m:rMargin m:val="0" /> <m:defJc m:val="centerGroup" /> <m:wrapIndent m:val="1440" /> <m:intLim m:val="subSup" /> <m:naryLim m:val="undOvr" /> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"   DefSemiHidden="true" DefQFormat="false" DefPriority="99"   LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Normal" /> <w:LsdException Locked="false" Priority="9" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="heading 1" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /> <w:LsdException Locked="false" Priority="39" Name="toc 1" /> <w:LsdException Locked="false" Priority="39" Name="toc 2" /> <w:LsdException Locked="false" Priority="39" Name="toc 3" /> <w:LsdException Locked="false" Priority="39" Name="toc 4" /> <w:LsdException Locked="false" Priority="39" Name="toc 5" /> <w:LsdException Locked="false" Priority="39" Name="toc 6" /> <w:LsdException Locked="false" Priority="39" Name="toc 7" /> <w:LsdException Locked="false" Priority="39" Name="toc 8" /> <w:LsdException Locked="false" Priority="39" Name="toc 9" /> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /> <w:LsdException Locked="false" Priority="10" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Title" /> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /> <w:LsdException Locked="false" Priority="11" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /> <w:LsdException Locked="false" Priority="22" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Strong" /> <w:LsdException Locked="false" Priority="20" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /> <w:LsdException Locked="false" Priority="59" SemiHidden="false"    UnhideWhenUsed="false" Name="Table Grid" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /> <w:LsdException Locked="false" Priority="1" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 1" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 1" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 1" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /> <w:LsdException Locked="false" Priority="34" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /> <w:LsdException Locked="false" Priority="29" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Quote" /> <w:LsdException Locked="false" Priority="30" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 1" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 1" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 2" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 2" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 2" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 2" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 2" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 3" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 3" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 3" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 3" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 3" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 4" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 4" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 4" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 4" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 4" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 5" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 5" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 5" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 5" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 5" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 6" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 6" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 6" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 6" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 6" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /> <w:LsdException Locked="false" Priority="19" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /> <w:LsdException Locked="false" Priority="21" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /> <w:LsdException Locked="false" Priority="31" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /> <w:LsdException Locked="false" Priority="32" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /> <w:LsdException Locked="false" Priority="33" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Book Title" /> <w:LsdException Locked="false" Priority="37" Name="Bibliography" /> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /> </w:LatentStyles> </xml><![endif]--><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="color: #800080;">[Flat File Source [1]] Error: The column delimiter for column &#8220;ColumnName&#8221; was not found.<br />
[Flat File Source [1]] Error: An error occurred while processing file &#8220;MyTextFile&#8221; on data row [nnnn].<br />
Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on component &#8220;Flat File Source&#8221; (1) returned error code 0xC0202092.  The component returned a failure code when<em> etc etc&#8230;</em></span></span></p>
<p><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="color: #800080;"><span style="color: #000000;">Now this was <span style="text-decoration: underline;">despite</span> the Error Output Disposition for this column being set to &#8220;Redirect Row&#8221;. So regardless of how I configured the Error Handling of the source, a single bad row would kill the load of the file.</span></span></span></p>
<p><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="color: #800080;"><span style="color: #000000;"><a title="BI Thoughts and Theories : Handling Flat Files with Varying Numbers of Columns" href="http://agilebi.com/cs/blogs/jwelch/archive/2007/05/07/handling-flat-files-with-varying-numbers-of-columns.aspx">Courtesy of a method described by jwelch at AgileBI.com</a> I approached the issue by importing the entire contents of the file into a single column, then parsing it in a script task. So the first step was to import the entire text file into a database as a single column. This can be done by configuring the connection manager as below, setting the single column as delimited by the row delimiter:</span></span></span></p>
<div class="wp-caption alignnone" style="width: 536px"><img title="Configuring the Flat File for a Single Column import of all data" src="http://www.bimonkey.com/uploads/ssis/flatfilesinglecolumn1.jpg" alt="b" width="526" height="237" /><p class="wp-caption-text">Fig 1: Configuring the Flat File for a Single Column import of all data</p></div>
<p><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="color: #800080;"><span style="color: #000000;">Then I processed the data from the database table in a script task acting as a transformation on the Data Flow, with a script that read pretty much like jwelch&#8217;s. It splits the data via a delimiter using the VB Split() function, with the advantage that you can handle cases where there is an incorrect number of columns, and fixing a row in a database for reload is a lot easier than trying to find and fix a row in a massive text file.</span></span></span></p>
<p>Example script:</p>
<pre><span style="font-family: Courier; font-size: x-small;"><span style="color: #0000ff;">Public Class</span> ScriptMain

    <span style="color: #0000ff;">Inherits </span>UserComponent
    <span style="color: #0000ff;">Private </span>columnDelimiter() As Char = CType(",", Char())
</span></pre>
<pre><span style="font-family: Courier; font-size: x-small;">    <span style="color: #0000ff;">Public Overrides Sub</span> Input0_ProcessInputRow(<span style="color: #0000ff;">ByVal </span>Row <span style="color: #0000ff;">As </span>Input0Buffer)

        <span style="color: #0000ff;">Dim </span>rowValues <span style="color: #0000ff;">As </span>String() </span></pre>
<pre><span style="font-family: Courier; font-size: x-small;">        rowValues = Row.Line.Split(columnDelimiter)
</span></pre>
<pre><span style="font-family: Courier; font-size: x-small;"><span style="color: #008000;">        ' Test Correct number of rows</span>
        <span style="color: #0000ff;">If </span>rowValues.GetUpperBound(0) &lt;&gt; 2 Then
<span style="color: #008000;">
</span></span><span style="color: #008000;"><span style="font-family: Courier; font-size: x-small;">            </span></span><span style="font-family: Courier; font-size: x-small;"><span style="color: #008000;">'Row is not complete - Handle error</span>
</span><span style="font-family: Courier; font-size: x-small;">            </span><span style="font-family: Courier; font-size: x-small;">Row.Column001_IsNull = True
</span><span style="font-family: Courier; font-size: x-small;">            </span><span style="font-family: Courier; font-size: x-small;">Row.Column002_IsNull = True
</span><span style="font-family: Courier; font-size: x-small;">            </span><span style="font-family: Courier; font-size: x-small;">Row.Column003_IsNull = True

        <span style="color: #0000ff;">Else</span>

<span style="color: #008000;">            ' Row is OK, output values</span>
            Row.</span><span style="font-family: Courier; font-size: x-small;">Column001</span><span style="font-family: Courier; font-size: x-small;"> = rowValues.GetValue(0).ToString()
            Row.</span><span style="font-family: Courier; font-size: x-small;">Column002</span><span style="font-family: Courier; font-size: x-small;"> = </span><span style="font-family: Courier; font-size: x-small;">rowValues.GetValue(1).ToString()</span><span style="font-family: Courier; font-size: x-small;">
            Row.</span><span style="font-family: Courier; font-size: x-small;">Column003</span><span style="font-family: Courier; font-size: x-small;"> = </span><span style="font-family: Courier; font-size: x-small;">rowValues.GetValue(2).ToString()</span><span style="font-family: Courier; font-size: x-small;">
</span><span style="font-family: Courier; font-size: x-small;"><span style="color: #0000ff;">
        End If

    End Sub
</span></span></pre>
<pre><span style="color: #0000ff;"><span style="font-family: Courier; font-size: x-small;">End Class</span></span></pre>
<p>Except mine had 180 columns(!), which caused me a fair amount of mouse clicking to set up all the output columns on the Script Component. The file came through, however, successfully bypassing the flaw in the Flat File Source.</p>
<p><a title="Jamie Thompson @ SSIS Junkie" href="http://blogs.conchango.com/jamiethomson/default.aspx">Jamie Thompson</a> offers a <a title="SSIS Nugget: Extracting data from unstructured files " href="http://blogs.conchango.com/jamiethomson/archive/2006/07/14/SSIS-Nugget_3A00_-Extracting-data-from-unstructured-files.aspx">slightly different approach</a>, and there are some useful tips in the comments for that post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bimonkey.com/2009/06/flat-file-source-error-the-column-delimiter-for-column-columnname-was-not-found/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flat File Import tips</title>
		<link>http://www.bimonkey.com/2009/06/flat-file-import-tips/</link>
		<comments>http://www.bimonkey.com/2009/06/flat-file-import-tips/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 00:01:17 +0000</pubDate>
		<dc:creator>BI Monkey</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Flat File]]></category>

		<guid isPermaLink="false">http://www.bimonkey.com/?p=324</guid>
		<description><![CDATA[I was importing some flat files recently and by virtue of forgetting my own best practices managed to create headaches for myself. So here&#8217;s a couple of BI Monkey aspirins to ensure your imports go well: Tip 1 : Always import the columns of your file into varchars big enough to take the contents of [...]]]></description>
			<content:encoded><![CDATA[<p>I was importing some flat files recently and by virtue of forgetting my own best practices managed to create headaches for myself. So here&#8217;s a couple of BI Monkey aspirins to ensure your imports go well:</p>
<p><strong>Tip 1 : Always import the columns of your file into varchars big enough to take the contents of the column</strong></p>
<p>Flat files have the habit of containing bad data &#8211; strings instead of numerics being the worst culprit, with oversize fields and unexpected delimiters being the close runners up in the trouble stakes. So if you want to avoid errors importing the file, pull everything you can into suitably big varchars. That way you avoid data conversion and truncation errors. It&#8217;s much easier to deal with these issues once the fields are in the database, as you can fix a single broken row far more easily in a database than in a massive text file.</p>
<p><strong>Tip 2: Always TRIM the contents of the columns you are pulling in</strong></p>
<p>Unless you desperately need those trailing spaces, TRIM them in a Derived Column Transform as part of the import, particularly if you are pulling in from a Fixed With file. This prevents database bloat &#8211; if you have a 100 character wide column which is just a &#8216;Y&#8217; with 99 trailing spaces, the database will still store 100 characters &#8211; 99 bytes of junk &#8211; over a million rows thats nearly 100MB. If you trim it you pass 1 byte to the database, and if it goes into a varchar, you will only store one byte of data. Otherwise it&#8217;s very easy to have Gigabyte sized import tables which actually contain a few hundred MB of useful data.</p>
<p>Please feel free to add any other hints and tips in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bimonkey.com/2009/06/flat-file-import-tips/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Flat File Connection Manager and Source</title>
		<link>http://www.bimonkey.com/2009/05/the-flat-file-connection-manager-and-source/</link>
		<comments>http://www.bimonkey.com/2009/05/the-flat-file-connection-manager-and-source/#comments</comments>
		<pubDate>Sat, 23 May 2009 01:28:07 +0000</pubDate>
		<dc:creator>BI Monkey</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Flat File]]></category>

		<guid isPermaLink="false">http://www.bimonkey.com/?p=142</guid>
		<description><![CDATA[The Flat File Source is one of the simplest sources to configure, but conversely the Connection Manager it uses is the one that requires the most manual configuration. As the two are inseparable I will cover them both in this (somewhat lengthy) post. The sample package can be found here for 2008 and guidelines on [...]]]></description>
			<content:encoded><![CDATA[<p>The Flat File Source is one of the simplest sources to configure, but conversely the Connection Manager it uses is the one that requires the most manual configuration. As the two are inseparable I will cover them both in this (somewhat lengthy) post.</p>
<p>The sample package can be found <a title="SQL 2008 Flat File Source Sample (Right click, Save as)" href="http://www.bimonkey.com/uploads/componentreview/flatfilesource.zip">here for 2008</a> and guidelines on use are <a title="Using samples from BI Monkey" href="../using-ssis-samples-from-this-site/">here</a>.</p>
<h2><strong>Configuring The Flat File Connection Manager</strong></h2>
<p>This Connection Manager is the means provided for accessing file based data sources. In terms of configuration it is probably the component that requires the most manual input because so little of the metadata can be obtained from the source itself, unlike a relational source for example.</p>
<p><span style="text-decoration: underline;">The General Tab</span></p>
<div class="wp-caption alignnone" style="width: 557px"><img title="The General Tab of the Flat File Connection Manager" src="http://www.bimonkey.com/uploads/componentreview/flatfile1.jpg" alt="b" width="547" height="252" /><p class="wp-caption-text">Fig 1: The General Tab of the Flat File Connection Manager</p></div>
<p>The first thing you are required to do when creating a Flat File Connection Manager is to select a file. This means if the file does not exist yet you will have to create a placeholder file otherwise you won&#8217;t be able to proceed. Once a file has been selected the first page of options on the General tab become available. Note absolutely no information is derived from the source file &#8211; as an a example, it will not autodetect a CSV file and prefill anything for you even if you select a CSV file type.</p>
<p>The first set of options are to set the Locale, whether the file is in Unicode format and what Code Page to use. In practice you are unlikely to change these options very often, unless data is coming from a country other than your own.</p>
<div class="wp-caption alignnone" style="width: 449px"><img title="More of the General Tab of the Flat File Connection Manager" src="http://www.bimonkey.com/uploads/componentreview/flatfile2.jpg" alt="b" width="439" height="160" /><p class="wp-caption-text">Fig 2: More of the General Tab of the Flat File Connection Manager</p></div>
<p>Below the dividing line come the basic file information settings. The most important of these is the Format. Your options are:</p>
<ul>
<li><strong>Delimited</strong> &#8211; most common, where each column is separated by a character such as a comma (CSV), Tab or Space</li>
<li><strong>Fixed Width</strong> &#8211; common from mainframes &#8211; a file where each column width is a fixed number of characters</li>
<li><strong>Ragged Right</strong> &#8211; the same as fixed width except the last column which will terminate with a carriage return at the end of the data item (<a title="Fun with SSIS and Fixed Width Flat File Exports" href="http://www.bimonkey.com/2008/11/fun-with-ssis-and-fixed-width-flat-file-exports/">read how I learned this the hard way</a>)</li>
</ul>
<p>The next set of options are</p>
<ul>
<li><strong>Text Qualifier</strong> &#8211; a symbol that encloses text strings &#8211; commonly a double quote (&#8220;) &#8211; needed when your text strings may contain the delimiter character &#8211; only for Delimited Format files</li>
<li><strong>Header row delimiter</strong> &#8211; The end of line delimiter in the header rows</li>
<li><strong>Header rows to skip</strong> &#8211; Number of rows to skip before attempting to read in data. Useful if the text file has rows of header data which is of no relevance to the data flow.</li>
<li><strong>Column names in the first data row</strong> &#8211; Checkbox to indicate if the first row has the column names in it. If present the connection manager will map these names in the next tab</li>
</ul>
<p><span style="text-decoration: underline;">The Columns Tab</span></p>
<p>This tab behaves differently depending on whether you selected Delimited or Fixed Width / Ragged Right in the General Tab.</p>
<div class="wp-caption alignnone" style="width: 449px"><img title="The Columns Tab of the Flat File Connection Manager for Delimited Files" src="http://www.bimonkey.com/uploads/componentreview/flatfile3.jpg" alt="Fig 3: The Columns Tab of the Flat File Connection Manager for Delimited Files" width="439" height="224" /><p class="wp-caption-text">Fig 3: The Columns Tab of the Flat File Connection Manager for Delimited Files</p></div>
<p>If you are loading a delimited file, the tab gives you the option to specify the Row Delimiter (i.e. the end of row character) and the Column Delimiter (the character that separates data items). If you have these set correctly, a preview will be displayed showing a few rows of sample data, as below:</p>
<div class="wp-caption alignnone" style="width: 448px"><img title="The Columns Tab of the Flat File Connection Manager for Fixed Width Files" src="http://www.bimonkey.com/uploads/componentreview/flatfile4.jpg" alt="Fig 4:The Columns Tab of the Flat File Connection Manager for Fixed Width Files" width="438" height="241" /><p class="wp-caption-text">Fig 4:The Columns Tab of the Flat File Connection Manager for Fixed Width Files</p></div>
<p>If you are loading a Fixed Width or Ragged Right file, you will be presented with a screen where you manually set the columns. For Fixed Width, you first need to set the overall row width &#8211; this can be done either by dragging the red line which marks the end of a row in the GUI, or entering the Row width in the text box below the GUI. For Ragged Right the end of line is identified by the Row Delimiter character and does not need to be manually set in the GUI. The data should then start looking like rows of data. To then set each column click and place a black line (which is draggable) to mark where each column starts / ends. For a big file this can be a pain, so you can skip this and set it in the Advanced tab if you have the file definition to hand, which I will cover in the next section.</p>
<p><span style="text-decoration: underline;">The Advanced Tab</span></p>
<p>Again, this tab has different options depending on the file type selected.</p>
<div class="wp-caption alignnone" style="width: 452px"><img title="The Advanced Tab of the Flat File Connection Manager" src="http://www.bimonkey.com/uploads/componentreview/flatfile5.jpg" alt="Fig 5: The Advanced Tab of the Flat File Connection Manager" width="442" height="231" /><p class="wp-caption-text">Fig 5: The Advanced Tab of the Flat File Connection Manager</p></div>
<p>If a Delimited file type is selected, you will able to set the following properties:</p>
<ul>
<li><strong>Name </strong>- the column name</li>
<li><strong>Column Delimiter</strong> &#8211; the character that terminates the column. This can be manually entered or selected form a drop down. An interesting feature is that because this can vary by column, it is possible to have different delimiters splitting columns within the same row.</li>
<li><strong>DataType</strong> &#8211; by default this will be a 50 wide string [DT_STR] &#8211; but if you click the <strong>Suggest Types</strong> button below the properties pane, you can fire a wizard which will sample the data and try and work out the smallest applicable data type to use for the columns. Beware this will apply the results of the wizard to all columns.</li>
<li><strong>TextQualified</strong> &#8211; A boolean to say whether the Text Qualifier specified in the General tab applies to thos column.</li>
</ul>
<p>If a Fixed Width file type is selected, you get these options instead:</p>
<ul>
<li><strong>Name</strong></li>
<li><strong>InputColumnWidth </strong>- the width of the Incoming column. If you bypassed the GUI in the Columns tab, here is where you would manually set each column width.</li>
<li><strong>DataType </strong>- by default this will a string [DT_STR]. The Suggest Types button is still clickable but seems to have no effect.</li>
<li><strong>OutputColumnWidth </strong>- this is the width of the column the component will output &#8211; by default as wide as the incoming column. You may want to shrink this if for example the column is 6 wide but you know it will only ever have a single character in it.</li>
<li><strong>TextQualified</strong></li>
</ul>
<p>If you are manually configuring a file definition, the New and Delete buttons will insert and delete new columns as required.</p>
<p><span style="text-decoration: underline;">The Preview Tab</span></p>
<p>At this point, the preview tab will simply display your correctly configured file in all its glory.</p>
<h2><strong>Configuring The Flat File Source, and its &#8216;hidden&#8217; options<br />
</strong></h2>
<p>In the main component editor, all that needs to be done is to select the Flat File connection manager already constructed, choose how to treat nulls in the source and choose your columns.</p>
<p>However the flat file source has a few of extra properties hidden in the Advanced Editor.  First, on the Component Properties tab under Custom Properties is a Property called FileNameColumnName &#8211; which will add a column to the component that contains the file name. The second, on the  Input and Output properties tab, under the Custom Properties of the Output Columns is the <strong>FastParse </strong>option. For specific numeric and date types and formats, this offers a different parsing engine (i.e. something that tries to convert the text into the data type you expect) which is allegedly faster, as per <a title="Fast Parse" href="http://msdn.microsoft.com/en-us/library/ms139833.aspx">MSDN documentation here</a>. However I did some loose testing and found performance actually degraded in some cases, and when it did change, it wasn&#8217;t by a significant margin &#8211; especially as reading flat files is so blisteringly fast in the first place. I would suggest ignoring this feature unless you have a specific performance problem to address. Finally, in the same place there is the <strong>UseBinaryFormat </strong>option for when you want to pass through raw binary data.</p>
<h2><strong>Summary</strong></h2>
<p>The Flat File Source is the simplest data source to configure &#8211; however the Flat File connection manager it needs requires significant manual input to set up correctly. The Connection manager does offer a very high degree of flexibility in how you handle data coming from flat file sources. Reading Flat Files is very very fast, so if you experience performance issues it&#8217;s more likely to be tied to network or disk problems that the package itself.</p>
<p>MSDN Documentation for the Flat File Source can be found here for <a title="SQL 2008 Flat File Source" href="http://msdn.microsoft.com/en-us/library/ms139941.aspx">2008</a> and  and here for <a title="SQL 2005 Flat File Source" href="http://msdn.microsoft.com/en-us/library/ms139941(SQL.90).aspx">2005</a>.</p>
<p>MSDN Documentation for the Flat File Connection Manager can be found here for <a title="SQL 2008 Flat File Connection Manager" href="http://msdn.microsoft.com/en-us/library/ms140266.aspx">2008</a> and  and here for <a title="SQL 2005 Flat File Connection Manager" href="http://msdn.microsoft.com/en-us/library/ms140266(SQL.90).aspx">2005</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bimonkey.com/2009/05/the-flat-file-connection-manager-and-source/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fun with SSIS and Fixed Width Flat File Exports</title>
		<link>http://www.bimonkey.com/2008/11/fun-with-ssis-and-fixed-width-flat-file-exports/</link>
		<comments>http://www.bimonkey.com/2008/11/fun-with-ssis-and-fixed-width-flat-file-exports/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 04:35:53 +0000</pubDate>
		<dc:creator>BI Monkey</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Flat File]]></category>

		<guid isPermaLink="false">http://www.bimonkey.com/?p=25</guid>
		<description><![CDATA[For reasons best kept to myself, I have been trying to move some data from SQL Server 2008 into Oracle on two unconnected machines. The best way of doing this &#8211; given the tools to hand* &#8211; appeared to be export from SQL2008 to flat files and suck it into Oracle via Data Manager (DM). [...]]]></description>
			<content:encoded><![CDATA[<p>For reasons best kept to myself, I have been trying to move some data from SQL Server 2008 into Oracle on two  unconnected machines. The best way of doing this &#8211; given the tools to hand* &#8211; appeared to be export from SQL2008 to flat files and suck it into Oracle via Data Manager (DM). Because apparently a simple &#8220;import text file&#8221; feature in Oracle is too much to ask for from most client tools. All hail SSMS, all curse SQL Developer. Due to issues with the data containing common delimiter characters, I decided to output to a Fixed Width flat file.</p>
<p>I subsequently had a barrel of laughs trying to get things into Data Manager because of its expectations of what constitutes a flat file versus what SSIS thinks is a flat file. For once i&#8217;m going to blame both parties equally for this mess, as both tools do odd and annoying things in a very non-transparent manner.</p>
<p>DM didn&#8217;t take the default flat file as it didn&#8217;t acknowledge what passed in SSIS for a row delimiter (the character at the end of the line that signifies a new row) so I decided to switch to Ragged Right as that has a specifiable row delimiter. Data Manager liked this a bit more, but complained that the last column of each data file terminated unexpectedly early.</p>
<p>It turns out that Ragged Right format trims trailing spaces from the last column &#8211; so if you have a column 8 characters wide, but only 4 characters in it, the last column will show the row delimiter after the 4th character. So Ragged Right isn&#8217;t truly &#8220;Fixed Width&#8221; &#8211; more &#8211; &#8220;Fixed Width, apart from the last column&#8221;. It&#8217;s counterintuitive, but if you read the documentation, it is behaving as intended, and fortunately there is an alternative approach.</p>
<p>The next step was to choose Fixed Width with an added column for row delimiter (an option when building your Flat File connector). This ensures every column is output at the full width of the column, even for the last one.</p>
<p>Well, almost. What I discovered next is that Numeric columns have been &#8211; regardless of size &#8211; all output with a width of 260. So your single digit integer gets output as 259 characters of spaces and a single numeric. This odd behaviour is controlled by the InputColumnWidth property (found on the advanced page for each column), rather than the expected OutputColumnWidth property, which for some reason is not configurable for numeric fields. To output a column just as wide as the numeric field, you need to set the InputColumnWidth to the Precision of the field, plus one for the decimal point and plus one for a minus symbol if the field is signed. Hence a field of precision 4, scale 2 &#8211; such as 21.13 &#8211; needs a InputColumnWidth of 5 to take all the output characters. If the numeric field is signed and carrying negative numbers &#8211; you need another point on there, so -21.13 would need an InputColumnWidth of 6 to export successfully.</p>
<p>Of course, Data Manager expects a precision 4 numeric to only be 4 characters wide, so when setting the precision in the SQLText Designer, you need to set the precision to match the InputColumnWidth used to export the field as well.</p>
<p>And that, my fellow BI monkeys, is how I wasted a full working day trying to get 14 text files from one database to another. It has done nothing to endear me to Oracle, that&#8217;s for sure.</p>
<p>* which includes that trusty ETL tool, a USB memory stick <img src='http://www.bimonkey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.bimonkey.com/2008/11/fun-with-ssis-and-fixed-width-flat-file-exports/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

