Showing posts with label Include. Show all posts
Showing posts with label Include. Show all posts

Sunday, September 23, 2012

BIML Include

On of the big risks is that BIML file have a tendency to become “LARGE” and thus become unreadable. Luckily you can use the Include directive to cut you BIML into readable blocks. For me a rule of thumb is a 100 line or less. Based on the script I did here: http://biml101.blogspot.nl/2012/09/biml-add-row-number-to-file-export.html I brought the Flat File definitions and the scripcompent C# part to external txt files. This also increases the reusability of code.!
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
    <Annotations>
        <Annotation>
            File: Add.RowNumber.Include.biml
            Demo on using the Include file
            Enviroment:
            DB: MS-SQL2012
            BIML: 1.6 VS2010 BIDS Helper
            (c) John Minkjan biml101.blogspot.com
        </Annotation>
    </Annotations>
    <FileFormats>
        <#@ include file="C:\BIML\FFF\FFF AdventureWorks2012 Person Address.txt" #>
    </FileFormats>
    <Connections>
        <#@ include file="C:\BIML\CN\CnOleDBAdventureWorks2012.txt" #>           
        <FlatFileConnection Name ="CnFFAdventureWorks2012PersonAddress"
                            FileFormat ="FFF AdventureWorks2012 Person Address"
                            FilePath="C:\AdventureWorks2012.Person.Address.dat"></FlatFileConnection>
    </Connections>
    <Packages>
        <Package Name="Add.RowNumber.Include" ConstraintMode="Linear">
            <Tasks>
                <Dataflow Name="DFT Add Rownumber">
                    <Transformations>
                        <OleDbSource Name ="ODS AdventureWorks2012 Person Address"
                                     ConnectionName ="CnOleDBAdventureWorks2012">
                            <DirectInput>
                                SELECT [AddressID]
                                ,[AddressLine1]
                                ,[AddressLine2]
                                ,[City]
                                ,[StateProvinceID]
                                ,[PostalCode]
                                ,[rowguid]
                                ,[ModifiedDate]
                                FROM [AdventureWorks2012].[Person].[Address]
                            </DirectInput>                       
                        </OleDbSource>
                        <DerivedColumns Name="DC ADD RowNumber Column">
                            <Columns>
                                <Column Name="RowNumber" DataType ="Int64">0</Column>
                            </Columns>
                        </DerivedColumns>
                        <ScriptComponentTransformation Name ="SC Add RowNumber">
                            <ScriptComponentProject>
                                <#@ include file="C:\BIML\SC\SCP AddRowNumber.txt" #>
                            </ScriptComponentProject>
                        </ScriptComponentTransformation>
                       
                        <FlatFileDestination Name ="FFD AdventureWorks2012 Person Address"
                                             ConnectionName ="CnFFAdventureWorks2012PersonAddress"
                                             Overwrite ="true">
                       
                        </FlatFileDestination>
                    </Transformations>
                </Dataflow>
            </Tasks>
        </Package>
    </Packages>
</Biml>
Till Next Time