SSIS : How to handle Multi select lookup column values to be inserted in SQL Server Table

社会主义新天地 提交于 2019-12-22 12:32:43

问题


I have a requirement to extract Sharepoint list data and import them in SQL Server Tables.

I am able to do this using the SSIS Data Flows including Derived Columns and Data Conversion controls. I am also able to convert Single Line, Multi line, Date, lookup(Single selection) data types to the SQL data types.

But now, my question is for Lookup column with Multi Select :

  1. What should be the expression used in Derived Column- for converting the data to comma separated values?

    Below expression I am using to get the ID from lookup column for Single Selection.

    SUBSTRING(Business,1,FINDSTRING(Business,";#",1) - 1)

If you see above screen shot, from the Public List output, it shows Future Risk Mitigation Controls are semicolon separated with multiple values in one row.

At Derived column output, it has taken only first ID and placed in the Risk Controls column.

Now questions are :

  • Should we get these IDs comma separated and store it as varchar in SQL Table ?
  • OR, we should have multiple rows to separate the options.

For example,

ID    RiskControls
 1       1
 1       3

Also, I have another question related to the Data Import.

  1. Where do we need to set that, this package would drop or delete all the existing rows of the table and insert all of them again ?

Please help me on this.

Thank you, Mittal.


回答1:


This is odd, but there is another question on the forum today, which appears very similar: How to use Substring in SSIS

I would suggest parsing the controls in a script task and breaking them into multiple rows, if these will be important for analysis. It will be far more difficult to do that in SQL, comparatively.

For your other question, you can use an execute SQL task to issue a Truncate table statement prior to the data flow executing.



来源:https://stackoverflow.com/questions/25680597/ssis-how-to-handle-multi-select-lookup-column-values-to-be-inserted-in-sql-ser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!