Skip to content

Don't Repeat Your Biml - Include Files

Biml Wheel.

Are you using Biml so you won’t have to do the same tasks over and over and over again in multiple SSIS packages? If so, you probably don’t want to write the same Biml code over and over and over again either. Instead, you can move common code to separate files, centralize and reuse these files in many projects, and update code in one file to make changes to all projects. One of the ways to apply this Don’t Repeat Yourself software engineering principle in Biml is to use Include Files.

In addition to using Include Files, there are four other main ways you can avoid repeating your Biml code:

In this post we will look at how to use Include Files.

Include Files

You can think of Include Files like an automated copy and replace. The main Biml file copies all the code from the included file and pastes it into the main file. Below is a very simple example:


  <Package Name="Package">
      <#@ include file="Variables.biml" #>


<Variable Name="NewRows" DataType="Int32">0</Variable>
<Variable Name="UpdatedRows" DataType="Int32">0</Variable>
<Variable Name="UnchangedRows" DataType="Int32">0</Variable>

You use the include directive <#@ include file="…" #> to specify which file to include. When your Biml code is compiled, all code is copied from the included file and pasted instead of the include directive. It is therefore important that the included file only contains code that can replace the include directive without causing invalid syntax errors. In the example above, the include directive is used inside , so the included file must only contain elements.

You can include many file types, such as: .biml .txt .sql .cs and so on.

If the included file is located outside your project, you will have to use an appropriate file path. You can use both relative file paths and absolute file paths:

<!-- Relative File Path -->
<#@ include file="..\SharedCode\Variables.biml" #>

<!-- Absolute File Path -->
<#@ include file="C:\Biml\SharedCode\Variables.biml" #>

How do Include Files work?

1. The main file has an include directive. In this example, it has a red include directive:

Main file with five lines of code, included file with three lines of code.

2. All code from the included file is copied to the main file:

Arrow pointing from the main file&rsquo;s middle line to the included file.

3. The include directive in the main file is replaced with the code from the included file:

The main file&rsquo;s middle line has been replaced with the three lines from the included file.


Include Files work as an automated copy and replace. You can include many file types, such as .biml .txt .sql and .cs. The include directive <#@ include file=“CommonCode.biml” #> will be replaced by the contents of the included file.

If you need more advanced features like passing parameters and controlling logic before returning code, you can use CallBimlScript instead.

Share or Comment?

About the Author

Professional headshot of Cathrine Wilhelmsen.Cathrine Wilhelmsen is a Microsoft Data Platform MVP, BimlHero Certified Expert, international speaker, author, blogger, and chronic volunteer. She loves data and coding, as well as teaching and sharing knowledge - oh, and sci-fi, chocolate, coffee, and cats 🤓