Biml(或SSIS)似乎不想自动识别行Delimiter。如果没有在列列表的最后一列上手动设置的列到预期的行分隔符,则SSIS不会为该行正确设置分隔符。我猜测SSIS只是意味着行分隔符,即使它是在连接属性中设置的。除了编写问题并将最后一列的delmiter设置为预期的行分隔符之外,任何人都知道修复此问题(参见下面的“T”列)?
我检查了输出Connection的属性,它正确地将“RowDelimiter”声明为CRLF,但是如果你看一下
这是Biml文件:
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<OleDbConnection Name="Source" ConnectionString="Provider=SQLNCLI11;Server=localhost;Initial Catalog=test;Integrated Security=SSPI;">
</OleDbConnection>
<FlatFileConnection Name="Created" FilePath="D:\\created.dat" FileFormat="Changed">
<Expressions>
<Expression PropertyName="ConnectionString">@[$Package::FileDropRoot] + "\\"+REPLACE((DT_WSTR, 10)(DT_DBDATE)GETDATE(),"-","") + "." + "created.dat"</Expression>
</Expressions>
</FlatFileConnection>
</Connections>
<FileFormats>
<FlatFileFormat Name="Changed" ColumnNamesInFirstDataRow="true" HeaderRowDelimiter="CRLF" RowDelimiter="CRLF">
<Columns>
<Column Name="col1" DataType="String" Delimiter="Comma" ColumnType="Delimited" />
<Column Name="col2" DataType="String" Delimiter="Comma" ColumnType="Delimited"/>
<!-- this must be here in order to terminate the row -->
<Column Name="T" DataType="String" Delimiter="Comma" ColumnType="CRLF"/>
</Columns>
</FlatFileFormat>
</FileFormats>
<Packages>
<Package Name="Test" ConstraintMode="Linear" ProtectionLevel="EncryptSensitiveWithUserKey">
<Tasks>
<Dataflow Name="Test">
<Transformations>
<OleDbSource Name="Select Stagement" ConnectionName="Source">
<DirectInput>
Select * From Test
</DirectInput>
</OleDbSource>
<FlatFileDestination Name="UpdateFile" ConnectionName="Created">
</FlatFileDestination>
</Transformations>
</Dataflow>
</Tasks>
<Parameters>
<Parameter Name="FileDropRoot" DataType="String">D:\FileDrop</Parameter>
</Parameters>
</Package>
</Packages>
</Biml>
以下是带有上面T列的SSIS“代码”,请注意指定了行分隔符(导出文件中的换行符):
<DTS:ConnectionManager DTS:CreationName="FLATFILE" DTS:DTSID="{9CDCB838-2A42-4CCA-A59C-DC60E9B3A967}" DTS:ObjectName="Created" DTS:refId="Package.ConnectionManagers[Created]">
<DTS:ObjectData>
<DTS:ConnectionManager DTS:CodePage="1252" DTS:ColumnNamesInFirstDataRow="True" DTS:ConnectionString="D:\\created.dat" DTS:Format="Delimited" DTS:HeaderRowDelimiter="_x000D__x000A_" DTS:LocaleID="1033" DTS:RowDelimiter="_x000D__x000A_" DTS:TextQualifier="_x003C_none_x003E_" DTS:Unicode="True">
<DTS:FlatFileColumns>
<DTS:FlatFileColumn DTS:ColumnDelimiter="_x002C_" DTS:ColumnType="Delimited" DTS:CreationName="" DTS:DataType="303" DTS:DTSID="{D64391D4-4551-44E9-8539-4C473EB700AA}" DTS:ObjectName="col1" DTS:TextQualified="True">
</DTS:FlatFileColumn>
<DTS:FlatFileColumn DTS:ColumnDelimiter="_x002C_" DTS:ColumnType="Delimited" DTS:CreationName="" DTS:DataType="303" DTS:DTSID="{974ED1AD-7D72-4A65-A877-BADEC09DAF20}" DTS:ObjectName="col2" DTS:TextQualified="True">
</DTS:FlatFileColumn>
<DTS:FlatFileColumn DTS:ColumnDelimiter="_x000D__x000A_" DTS:ColumnType="Delimited" DTS:CreationName="" DTS:DataType="303" DTS:DTSID="{4347C3C1-39BD-40B1-B38F-526730FE7BFB}" DTS:ObjectName="T" DTS:TextQualified="True">
</DTS:FlatFileColumn>
</DTS:FlatFileColumns>
</DTS:ConnectionManager>
</DTS:ObjectData>
<DTS:PropertyExpression DTS:Name="ConnectionString">@[$Package::FileDropRoot] + "\\"+REPLACE((DT_WSTR, 10)(DT_DBDATE)GETDATE(),"-","") + "." + "created.dat"</DTS:PropertyExpression>
</DTS:ConnectionManager>
以下是没有上面T列的SSIS“代码”,请注意指定了行分隔符(导出文件中没有换行符):
<DTS:ConnectionManager DTS:CreationName="FLATFILE" DTS:DTSID="{79E9C576-FD53-4D4F-A07C-AED8D4CE72E6}" DTS:ObjectName="Created" DTS:refId="Package.ConnectionManagers[Created]">
<DTS:ObjectData>
<DTS:ConnectionManager DTS:CodePage="1252" DTS:ColumnNamesInFirstDataRow="True" DTS:ConnectionString="D:\\created.dat" DTS:Format="Delimited" DTS:HeaderRowDelimiter="_x000D__x000A_" DTS:LocaleID="1033" DTS:RowDelimiter="_x000D__x000A_" DTS:TextQualifier="_x003C_none_x003E_" DTS:Unicode="True">
<DTS:FlatFileColumns>
<DTS:FlatFileColumn DTS:ColumnDelimiter="_x002C_" DTS:ColumnType="Delimited" DTS:CreationName="" DTS:DataType="303" DTS:DTSID="{BBCA22D2-5D3E-47AC-AA0A-413C0C1A5CB2}" DTS:ObjectName="col1" DTS:TextQualified="True">
</DTS:FlatFileColumn>
<DTS:FlatFileColumn DTS:ColumnDelimiter="_x002C_" DTS:ColumnType="Delimited" DTS:CreationName="" DTS:DataType="303" DTS:DTSID="{44E567E4-BE78-432C-A8AC-C388E8BCFADC}" DTS:ObjectName="col2" DTS:TextQualified="True">
</DTS:FlatFileColumn>
</DTS:FlatFileColumns>
</DTS:ConnectionManager>
</DTS:ObjectData>
<DTS:PropertyExpression DTS:Name="ConnectionString">@[$Package::FileDropRoot] + "\\"+REPLACE((DT_WSTR, 10)(DT_DBDATE)GETDATE(),"-","") + "." + "created.dat"</DTS:PropertyExpression>
</DTS:ConnectionManager>
以下是我用于在数据库Connection
上创建表的脚本CREATE TABLE Test(col1 varchar(25),col2 varchar(25))
INSERT INTO Test
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2' UNION all
SELECT '1','2'
答案 0 :(得分:0)
您的假设不正确,因为最后一列的分隔符不应该是CRLF。您将在所有链接的示例中看到,虽然反直觉,但您的平面文件格式文件应使用行分隔符作为最终列的列分隔符。每隔一列都会使用您的&#34;标准&#34;列分隔符。是的,它从标题声明中重复了你的行分隔符应该是什么。
有些人玩鹅......