使用SSIS将csv文件中的数据导入数据库时​​,如何验证空字段? [英] how to validate empty fields while importing data from csv files to database using SSIS?

查看:256
本文介绍了使用SSIS将csv文件中的数据导入数据库时​​,如何验证空字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从包含用户记录的csv文件中导入数据.我在这里面临的问题是验证是否所有必填字段都存在.我需要检查所有行是否包含用户名(或其他一些值....).如果该行包含所有字段,那么我需要将其存储到表USERS中,否则如果缺少任何字段,则它应该存储在另一个表ERROR_USERS中.

例如:
ID名称密码部门
1,sushil,asdfgghh,rnd
2,shakun,rnd.

从上面的csv文件
第一条记录应存储到表USERS
第二个应该存储到ERROR_USERS(因为它不包含密码字段).

i have to import data from a csv file which contains records of users. the problem i face here is to verify that all required field is present. I need to check that all the lines contains the USER NAME(or some other values....).if the line contains all the fields then i need to store it into a table USERS else if any of the fields are missing then it should be stored in another table ERROR_USERS.

eg:
id name password dept
1, sushil, asdfgghh, rnd
2, shakun, , rnd.

from above csv file
first record should be stored to the table USERS
and second should be stored to ERROR_USERS(as it doesn''t contain the password field)

推荐答案

我认为没有默认工具可以验证CSV文件.您可以使用SCRIPT任务和优先约束"来读取和检查CSV文件的字段,您可以将流重定向到是插入到错误表"还是主表".希望我有所帮助.
I think there is no default tools to validate the CSV files. You can read and check the CSV files'' fields using the SCRIPT task and using Precedence Constraint, you can redirect the flow whether to insert to Error Table or Main table. Hope i have helped a lil bit.


这篇关于使用SSIS将csv文件中的数据导入数据库时​​,如何验证空字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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