Sql server 使用SSIS将Excel文件(带变量#列)加载到数据库中
我需要做一个Excel文件的例行导入。问题是Excel的列没有固定。例如,一个月,如果可以:Sql server 使用SSIS将Excel文件(带变量#列)加载到数据库中,sql-server,excel,ssis,Sql Server,Excel,Ssis,我需要做一个Excel文件的例行导入。问题是Excel的列没有固定。例如,一个月,如果可以: first_name last_name question_are_you_happy question_how_old_are_you John Smith no 32 Jane Doe yes 11 下个月就可以了 first_n
first_name last_name question_are_you_happy question_how_old_are_you
John Smith no 32
Jane Doe yes 11
下个月就可以了
first_name last_name question_favorite_color
John Smith blue
Jane Doe red
每个Excel都有公共列,如名字和姓氏,但其他“问题”列可能不同。我的目标是将数据加载到数据库表中,使其看起来像:
first_name last_name question answer
John Smith are_you_happy no
John Smith how_old_are_you 32
John Smith favorite_color blue
Jane Doe are_you_happy yes
Jane Doe how_old_are_you 11
Jane Doe favorite_color red
我知道在SSIS中有一个unpivot转换,但是它似乎无法处理可变数量的列?问题是我的源有不同名称的不同列。您知道所有可能的列名吗?是否有可能的最大列数(N)?我的意思是。。您可以尝试将整个数据(包括标题行)加载到具有-Column1、Column2…、ColumnN等列的临时表中。因此,表中也会有标题信息,可以使用TSQL或脚本提取标题数据并进行相应的操作。会指引你走向正确的方向