在 SQL Server 2005 中使用 SSIS 从平面文件导入时如何保留 NULL 值 [英] How do I retain NULL values when using SSIS to import from flat file in SQL Server 2005

查看:37
本文介绍了在 SQL Server 2005 中使用 SSIS 从平面文件导入时如何保留 NULL 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将记录导出到以|"分隔的平面文件似乎当我将这些记录导入新数据库时,SQL Server 将 NULL 值视为空字段.当记录/字段为 NULL 时,我的查询工作正常,因此我想找到一种方法来保留数据中的 NULL 值或将空白字段转换为 NULL 值.我假设前者会更容易,但我不知道该怎么做.任何帮助将不胜感激.

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.

推荐答案

在数据流的目标连接中,您可以检查一个属性,上面写着保留空值,只需检查一下.为什么这不是我永远不会知道的默认设置.

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.

嗯,那里发生了一些奇怪的事情.我可以建议您然后清理数据并将其更改为 null,您可以将其作为数据流的一部分来执行,也可以执行两个数据流,一个将数据插入到临时表中,然后运行执行 SQl 任务来进行清理up 然后创建一个数据流从临时表运行到真实表.

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.

这篇关于在 SQL Server 2005 中使用 SSIS 从平面文件导入时如何保留 NULL 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆