create table ExportTest_c001 ( c001 varchar(20) ) go create table ExportTest_c001c002 ( c001 varchar(20) , c002 varchar(20) ) go select @@servername DESKTOP-D6M6JCB create table ExportPackageTest ( s varchar(1000) , id int identity (1,1) ) go create view ExportPackageTest_vw as select s from ExportPackageTest go bulk insert ExportPackageTest_vw from 'C:\Users\nigel\OneDrive\Nigel\Articles\GenericFileImporter\Test\GenericImport\GenericImport\Export_c001.dtsx' select * from ExportPackageTest drop table #a go create table #a (i int primary key, j int, BlockType varchar(1000), txt varchar(1000)) delete #a declare @i int insert #a select top 1 id, id, 'DatabaseConnection', s from ExportPackageTest where s like '%DTS:ConnectionString=%' insert #a select top 1 id, id, 'FileConnection', s from ExportPackageTest where s like '%DTS:ConnectionString=%' and id > (select max(i) from #a) select top 1 @i = id+1 from ExportPackageTest where s like '% (select max(i) from #a) insert #a select top 1 id, id, 'FileCol1', s from ExportPackageTest where id = @i select top 1 @i = id from ExportPackageTest where s like '%%' and id > (select max(i) from #a) update #a set j = @i-1 where i = (select max(i) from #a) select top 1 @i = id+1 from ExportPackageTest where s like '% (select max(i) from #a) insert #a select top 1 id, id, 'TableCol1', s from ExportPackageTest where id = @i select top 1 @i = id from ExportPackageTest where s like '%%' and id > (select max(i) from #a) update #a set j = @i-1 where i = (select max(i) from #a) select top 1 @i = id+2 from ExportPackageTest where s like '% (select max(i) from #a) insert #a select top 1 id, id, 'FileCol2', s from ExportPackageTest where id = @i select top 1 @i = id from ExportPackageTest where s like '%%' and id > (select max(i) from #a) update #a set j = @i-1 where i = (select max(i) from #a) select top 1 @i = id+1 from ExportPackageTest where s like '%description="Specifies the name of the database object used to open a rowset."%' and id > (select max(i) from #a) insert #a select id, id, 'TableName', s from ExportPackageTest where id = @i select top 1 @i = id+1 from ExportPackageTest where s like '%%' and id > (select max(i) from #a) insert #a select id, id, 'ColMap1', s from ExportPackageTest where id = @i select top 1 @i = id-1 from ExportPackageTest where s like '%%' and id > (select max(i) from #a) update #a set j = @i-1 where i = (select max(i) from #a) select top 1 @i = id+2 from ExportPackageTest where s like '% (select max(i) from #a) insert #a select id, id, 'ColMap2', s from ExportPackageTest where id = @i select top 1 @i = id from ExportPackageTest where s like '%%' and id > (select max(i) from #a) update #a set j = @i-1 where i = (select max(i) from #a) Result select * from #a 26 26 DatabaseConnection DTS:ConnectionString="Data Source=DESKTOP-D6M6JCB;Initial Catalog=SSIS_Test;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;" /> 43 43 FileConnection DTS:ConnectionString="C:\Users\nigel\OneDrive\Nigel\Articles\SSIS_FileExport\FileExport_c001.txt"> 45 53 FileCol1 [dbo].[ExportTest_c001] 187 196 ColMap1 ' from #a where BlockType = 'DatabaseConnection' insert Export_Package_Template select i, 'DTS:ConnectionString="||FileName||">' from #a where BlockType = 'FileConnection' insert Export_Package_Template select i, 'name="OpenRowset">||TableName||' from #a where BlockType = 'TableName' insert Export_Package_Template select i, '||' + BlockType + '||' from #a where BlockType in ('FileCol1','TableCol1','FileCol2','ColMap1','ColMap2') select * from Export_Package_Template Result 1 2 16 8 18 19 24 25 27 28 29 34 35 44 45 ||FileCol1|| 54 55 56 57 58 59 60 61 69 70 71 73 74 81 82 true 86 91 92 93 98 99 100 104 105 ||TableCol1|| 113 114 116 ||FileCol2|| 122 123 124 125 126 134 135 0 139 ||TableName|| 143 147 152 156 1252 160 false 164 0 169 173 174 175 181 182 183 186 187 ||ColMap1|| 197 truncationRowDisposition="FailComponent" /> 198 199 201 ||ColMap2|| 207 208 209 213 214 221 227 233 234 235 236 237 238 239 240 245 246 247 248 249 250 251 252 253 254 256 257 259 260 262 266 267 268 269 271 272 274 278 282 285 286 291 292 294 296 297 298 299 300 301 302 303 304 305 306 307 309 310 311 DataSourceViewID 312 313 314 TableInfoObjectType 315 Table 317 318 319 320 ]]> 321