使用SSIS读取.dat文件并将数据存储在各种表中

时间:2017-03-24 04:46:12

标签: c# dynamics-crm-online ssis-2012

我需要读取.dat文件(每行包含不同的列)并插入SQL Server数据库表(插入父级(第二行和几个基于第一列值的行),然后是剩余的子记录) 。请建议解决方案。第一行包含文件名和生成日期。

测试DOC文件如下:

HDR~GO_123_ROS_20111004_00189794.DAT~20111003 044800~123~20111004 045101~20111004 023659~1
PRA~1234567~20110629~20111110~10602402~MISS~Bloggs~Laura~Claire~~~~F~19880612~JH342567C~~~20110531~~A~~~~~~~~~~~~~~~Ex-employee and 

Applicant~LAURA.BLOGGS@NHS.NET~20010226~~20111110 112826~~~~~
PHA~1234567~15691675~H1~1743762397~20110704~~20111109 160911
STA~1234567~2075698~20090420~~NHS_REC_CHECKLIST~~~~~~~~~~~22/04/2009 00:00~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~20090427 115502
ADA~1234567~9028057~HOME~GB~Yes~The Old Engine House~Wind Park~Wind Hill~Hatbury~SHR~SS1 2AA~GB~20110704~~20111109 160911
ASA~1234567~936458~20110601~47121231~20060727~E~10602402~ACTIVE_ASSIGN~Active Assignment~X~123 Monthly~Calendar 

Month~96867~Y~1117262~~~~~B~Y~0~W~37.5~0~~328245~4741068~6971867|AHPs Maternity Therapy Assistant Bank|S9C|Bank|~NHS|XR02|Review Body Band 2~XR023~~~Additional 

Clinical Services|Helper/Assistant~Default Home|Standard User||~||~~~~~~~~~~~~~
ORA~128111~070 6 Domestic (BRO)~NHS_TM~19510101~~~~~070E642~548444~~96804~20061019 233601~070E642
LCA~552921~070 z Maternity LWH~Maternity Town Hospital~~Maternity~Town Wells Hospital~~~~~GB~~~Y~~~~~~~20110803 161310
ETA~1234567~17453990~NHS CRB and Vetting Checklist~NHS CRB and Vetting Checklist~~~~~~~~~~Enhanced~10/07/2006 00:00~02/01/2007 00:00~1150189058~Post To Be 

Offered~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~20111231 064907
ETA~201346~957384~ NHS Regs and Memships~NHS Regs and Memships~Nursing and Midwifery Council~ 94I0864E~ 31/08/2012 00:00:00~~ 31/08/2013 

00:00:00~~~~~~~~~~~~~~~~~~~~~~~~~~ Nursing and Midwifery Council~ Sub-Part 1 RNLD (Learning Disabilities)~~~~~~~~~~~~~No~No~No~No~~~~ 20110719 232041
CRA~1234567~4910890~7648535~SP~N~~~20100601~~20100610 163220
CMA~1234567~10005280~PERSONAL~ACHIEVED~NHS|KSF|Health, Safety and Security C3|Core~20091027~20130706~1 - Level 1~123~~~~20091101 070336
QLA~1234567~4698382~Bachelors Degree~Occupational Therapy~ATTAIN~02:01~20100707~~~City University~UK~20101018 142415
ABA~1234567~43247770~Annual Leave Hours 1~AL~~20110923~20111228~~20111230~~20121226~~20121226~~~~~~D~~~~~~~~~~20111010 150639~~~~~~~~~~~
TRA~1234567~43247770~MEL - Module 4 - Safeguarding Family - ALL CLINICAL STAFF~Training 

Leave~Withdrawn~~20130918~09:15~20130918~15:00~20130918~09:15~20130918~15:00~~~~~~~~~~~~~~~20130725 100052
COA~1234567~937490~5507703~20110308~47121231~ABC~~~0702K161~~~~~1~20110308 103538
POA~768853~19510101~47121231~901335~901335|Maternity Hospital Bank Place Qualified|N9A|Bank|~~7012170~Additional Clinical Services~Healthcare Assistant~N9A~ 

1 个答案:

答案 0 :(得分:1)

如果您正在使用您在代码中指定的CRM Online,则无法直接写入CRM表。您必须使用诸如Kingswaysoft之类的扩展,它将通过公开的Web服务写入CRM实体。

http://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-365