<small id='UtGwd'></small><noframes id='UtGwd'>

      • <bdo id='UtGwd'></bdo><ul id='UtGwd'></ul>

      <legend id='UtGwd'><style id='UtGwd'><dir id='UtGwd'><q id='UtGwd'></q></dir></style></legend>

      1. <tfoot id='UtGwd'></tfoot>
      2. <i id='UtGwd'><tr id='UtGwd'><dt id='UtGwd'><q id='UtGwd'><span id='UtGwd'><b id='UtGwd'><form id='UtGwd'><ins id='UtGwd'></ins><ul id='UtGwd'></ul><sub id='UtGwd'></sub></form><legend id='UtGwd'></legend><bdo id='UtGwd'><pre id='UtGwd'><center id='UtGwd'></center></pre></bdo></b><th id='UtGwd'></th></span></q></dt></tr></i><div id='UtGwd'><tfoot id='UtGwd'></tfoot><dl id='UtGwd'><fieldset id='UtGwd'></fieldset></dl></div>

        在 SSIS 中将带有逗号分隔符的单列数据拆分为多列

        时间:2024-04-16
        <i id='IfA3g'><tr id='IfA3g'><dt id='IfA3g'><q id='IfA3g'><span id='IfA3g'><b id='IfA3g'><form id='IfA3g'><ins id='IfA3g'></ins><ul id='IfA3g'></ul><sub id='IfA3g'></sub></form><legend id='IfA3g'></legend><bdo id='IfA3g'><pre id='IfA3g'><center id='IfA3g'></center></pre></bdo></b><th id='IfA3g'></th></span></q></dt></tr></i><div id='IfA3g'><tfoot id='IfA3g'></tfoot><dl id='IfA3g'><fieldset id='IfA3g'></fieldset></dl></div>

              <tfoot id='IfA3g'></tfoot>

              <small id='IfA3g'></small><noframes id='IfA3g'>

                <tbody id='IfA3g'></tbody>
            • <legend id='IfA3g'><style id='IfA3g'><dir id='IfA3g'><q id='IfA3g'></q></dir></style></legend>

                  <bdo id='IfA3g'></bdo><ul id='IfA3g'></ul>
                  本文介绍了在 SSIS 中将带有逗号分隔符的单列数据拆分为多列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 SQL Server 中有一个包含 3 列的表,其中一个是包含由逗号分隔的串联列行的数据列.第一行也是我要创建的新表的标题行.所以基本上我想转这个.

                  I have a table in SQL Server with 3 columns, one of which is a data column containing rows of concatenated columns delimited by commas. The first row is also the header row of the new table I want to create. so basically I want to turn this.

                  Data      | ID | Source 
                  ====================
                  a,b,c,d,e | 1  | a.csv
                  
                  f,g,h,i,j | 2  | b.csv
                  

                  进入

                  a | b | c | d | e
                  =================
                  f | g | h | i | j
                  

                  使用 SSIS,我能想到的唯一方法是使用转储到数据列的文本文件中,然后将其作为平面文件源重新读取,但我宁愿避免创建额外的不必要的文件

                  Using SSIS, The only way i could think of doing it is using a dump into a text file of the data column and then re-read it as an flat file source, but I'd rather avoid creating extra unnecessary files

                  抱歉我使用 SSIS 2008

                  Sorry Im using SSIS 2008

                  推荐答案

                  您可以做的是按原样读取文件.并在脚本任务中拆分这些值.

                  What you can do is to read the file as is. And Split those values in a script task.

                  所以从源代码转到脚本任务.然后在作为输入列的脚本任务中,选择包含这些值的列 (InputColumn1).然后指定输出列(如果我是对的,我看到你有 5,所以指定 5 (OutputColumn1 - 5)).

                  So from source go to a script task. Then in the script task as input column, select the column containing those values (InputColumn1). Then specify the output columns (If I am right I see you have 5, so specify 5 (OutputColumn1 - 5)).

                  完成后,转到脚本本身(C#).

                  After that is done, go to the script itself (C#).

                  在:

                  public override void Input0_ProcessInputRow(Input0Buffer Row)
                  {
                  }
                  

                  在那里输入以下代码:

                  var ColumnValue = Row.InputColumn1.Split(',');
                  
                  Row.OutputColumn1 = ColumnValue[0];
                  Row.OutputColumn2 = ColumnValue[1];
                  Row.OutputColumn3 = ColumnValue[2];
                  Row.OutputColumn4 = ColumnValue[3];
                  Row.OutputColumn5 = ColumnValue[4];
                  

                  在脚本任务之后,Source 和 OutputCoulmns1-5 中的所有列都将可用,您可以做您必须做的事情.

                  After the script task all the columns from the Source as well as the OutputCoulmns1-5 will be available and you can do what you have to.

                  输出

                   Data      | ID | Source |OutputColumn1 |OutputColumn2|  etc. 3-5
                   ================================================================
                   a,b,c,d,e | 1  | a.csv  |  a           |  b
                  
                   f,g,h,i,j | 2  | b.csv  |  f           |  g
                  

                  有不清楚的地方请追问.

                  Please ask if something is not clear.

                  这篇关于在 SSIS 中将带有逗号分隔符的单列数据拆分为多列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 SQL Server 中将字符串拆分为给定行分隔符和列分隔符的表 下一篇:无法使用 Node.js 和 Tedious 连接到 SQL Server

                  相关文章

                  <legend id='o4Zpk'><style id='o4Zpk'><dir id='o4Zpk'><q id='o4Zpk'></q></dir></style></legend>

                  1. <small id='o4Zpk'></small><noframes id='o4Zpk'>

                      <bdo id='o4Zpk'></bdo><ul id='o4Zpk'></ul>
                  2. <i id='o4Zpk'><tr id='o4Zpk'><dt id='o4Zpk'><q id='o4Zpk'><span id='o4Zpk'><b id='o4Zpk'><form id='o4Zpk'><ins id='o4Zpk'></ins><ul id='o4Zpk'></ul><sub id='o4Zpk'></sub></form><legend id='o4Zpk'></legend><bdo id='o4Zpk'><pre id='o4Zpk'><center id='o4Zpk'></center></pre></bdo></b><th id='o4Zpk'></th></span></q></dt></tr></i><div id='o4Zpk'><tfoot id='o4Zpk'></tfoot><dl id='o4Zpk'><fieldset id='o4Zpk'></fieldset></dl></div>

                    <tfoot id='o4Zpk'></tfoot>