I've exported records to a flat file delimited by "|" and it seems that when I import those records into a new database , SQL Server treats the NULL values as empty fields. IMy queries worked properly when the records/fields were NULL and so I want to either find a way to retain the NULL values in the data or convert the blank fields to NULL values. I'm assuming the former would be easier, but I don't know how to do that. Any help would be appreciated.
我已将记录导出到由“|”分隔的平面文件中似乎当我将这些记录导入新数据库时,SQL Server将NULL值视为空字段。当记录/字段为NULL时,IMy查询正常工作,因此我想要找到一种方法来保留数据中的NULL值或将空白字段转换为NULL值。我假设前者会更容易,但我不知道该怎么做。任何帮助,将不胜感激。
3 个解决方案
#1
16
In your destination connection in the dataflow, there is a property that you can chceck that says Keep nulls, JUst check that. Why that isn't the default I'll never know.
在数据流中的目标连接中,有一个属性,您可以选择Keep nulls,JUst检查它。为什么这不是我永远不会知道的默认值。
Hmmm something stange going on there. I can suggest that you then clean the data and change it to null, you can either do this as part of the dataflow or do two dataflows, one which inserts the data into a staging table, then run an exectue SQl task to do the clean up and then create a dataflow to run fromthe staging table to the real table.
嗯那里有什么东西。我建议您然后清理数据并将其更改为null,您可以将其作为数据流的一部分执行,也可以执行两个数据流,一个将数据插入到临时表中,然后运行exectue SQl任务来执行清理然后创建一个数据流以从登台表运行到真实表。
#2
18
I just had the same problem. I resolved it by Changing the RetainNulls property in the properties of the Flat File Source in the Data Flow Task.
我刚遇到同样的问题。我通过在数据流任务中的平面文件源的属性中更改RetainNulls属性来解决它。
#3
0
in case anyone is looking how to do this when building the package programatically you need to set the variable in your CManagedComponentWrapper object
如果有人在以编程方式构建包时想要如何执行此操作,则需要在CManagedComponentWrapper对象中设置变量
CManagedComponentWrapper instanceSource = ComponentSource
...
instanceSource.SetComponentProperty("RetainNulls", true);
#1
16
In your destination connection in the dataflow, there is a property that you can chceck that says Keep nulls, JUst check that. Why that isn't the default I'll never know.
在数据流中的目标连接中,有一个属性,您可以选择Keep nulls,JUst检查它。为什么这不是我永远不会知道的默认值。
Hmmm something stange going on there. I can suggest that you then clean the data and change it to null, you can either do this as part of the dataflow or do two dataflows, one which inserts the data into a staging table, then run an exectue SQl task to do the clean up and then create a dataflow to run fromthe staging table to the real table.
嗯那里有什么东西。我建议您然后清理数据并将其更改为null,您可以将其作为数据流的一部分执行,也可以执行两个数据流,一个将数据插入到临时表中,然后运行exectue SQl任务来执行清理然后创建一个数据流以从登台表运行到真实表。
#2
18
I just had the same problem. I resolved it by Changing the RetainNulls property in the properties of the Flat File Source in the Data Flow Task.
我刚遇到同样的问题。我通过在数据流任务中的平面文件源的属性中更改RetainNulls属性来解决它。
#3
0
in case anyone is looking how to do this when building the package programatically you need to set the variable in your CManagedComponentWrapper object
如果有人在以编程方式构建包时想要如何执行此操作,则需要在CManagedComponentWrapper对象中设置变量
CManagedComponentWrapper instanceSource = ComponentSource
...
instanceSource.SetComponentProperty("RetainNulls", true);