Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ssis包的平面文件目标中保留空值_Ssis_Oledb_Ssis 2012_Dataflowtask_Flatfiledestination - Fatal编程技术网

如何在ssis包的平面文件目标中保留空值

如何在ssis包的平面文件目标中保留空值,ssis,oledb,ssis-2012,dataflowtask,flatfiledestination,Ssis,Oledb,Ssis 2012,Dataflowtask,Flatfiledestination,我已经创建了一个ssis包。在数据流任务中,我将数据从oledbsource传递到平面文件目标。我想在平面文件中保留空值,但它将变为空。在平面文件中,空值和空值之间没有区别。因此,如果使用应用程序或其他ssis包读取平面文件,则必须使用String.IsNullOrEmpty和IsNull等函数检查该值是否为null或空 即: 在脚本组件中,可以检查列值,如下所示: If Not Row.inCol_IsNull AndAlso _ Not String.IsNullOrEmpty(Row

我已经创建了一个ssis包。在数据流任务中,我将数据从oledbsource传递到平面文件目标。我想在平面文件中保留空值,但它将变为空。

在平面文件中,空值和空值之间没有区别。因此,如果使用应用程序或其他ssis包读取平面文件,则必须使用String.IsNullOrEmpty和IsNull等函数检查该值是否为null或空

即:

在脚本组件中,可以检查列值,如下所示:

If Not Row.inCol_IsNull AndAlso _
   Not String.IsNullOrEmpty(Row.InCol) Then

  'Do SomeThing
  Row.OutCol = Row.inCol

  Else

  Row.OutCol_IsNull = True

  En If

如果使用应用程序

 If not strValue is nothing andAlso _
    not string.IsNullOrEmpty(strvalue) then

 ' do something
 end If

@H.Fadlalah提供了一个如何处理从平面文件读取的空值的示例。我知道你想在平面文件中写入空值。如前所述,平面文件没有空值的概念。与SQL不同,它们没有数据类型。一切都是一根弦。平面文件中的NULL等于空字符串

从你的陈述中

我想在平面文件中保留空值,但它是空的

我只能假设您希望将文本NULL打印到平面文件中。 为此,可以使用派生列组件。将其放在OLE DB源和平面文件目标之间。在派生列组件内部,检测空值,并使用以下三元表达式将它们从真空值转换为字符串值空值

ISNULL([MyColumn]) ? "NULL" : [MyColumn]

希望这有帮助。如果您还需要其他内容,请随时澄清您的问题。

在SSIS中使用派生列转换,请尝试以下代码。将[ColumnName]替换为您的列

ISNULL([ColumnName]) ? "NULL" : [ColumnName]