如何比较csv文件的标头与表列值 [英] How to compare header of csv file with table column values

查看:93
本文介绍了如何比较csv文件的标头与表列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有一个csv文件,其列如下所示。列名和列顺序可以更改。

Hi I have a csv file with the columns as below. The column names and order of columns can be changed.

DeptID | Dname | Loc或DeptName | Dept_id | Location或Loc_ID | Dept_ID1。

DeptID|Dname|Loc or DeptName|Dept_id|Location or Loc_ID|Dept_ID1.

我要求如果列中有不同的名称,我需要检查组合,如果有任何值匹配,我需要在insert语句中添加列。

I got a requirement that if the column comes with different names I need to check the combination , if any of the value matches, I need to add the columns in insert statement.

为此,我创建了一个表格 

For this I have created a table as 

create table DeptConfig(ID INT Identity(1,1),ColName VARCHAR(50),ColValue VARCHAR( 500)); colname值表示Dept Table的原始列名。
create table DeptConfig(ID INT Identity(1,1),ColName VARCHAR(50),ColValue VARCHAR(500)); The colname value represents the original column name of Dept Table.

推荐答案

您需要将数据发送到临时表并解析它以查看列数据值是否对应对于您预期的数据,如果是,请插入。
You need to send your data to a staging table and parse it to see if the column data values correspond to the data you are anticipating and if so, insert it.


这篇关于如何比较csv文件的标头与表列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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