This post is part 2 of a series on using Biml in BIDS Helper. This post builds on some of the information and the sample from the previous posts.
When I’m creating samples for SSIS, I often find it necessary to create supporting tables to go along with the package sample. One of the things I like about Biml is that you can define both your tables and packages in the language. Here’s an example of defining an OrderHeader and OrderDetail table in Biml:
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<OleDbConnection Name="DbConnection" ConnectionString="Server=.;Initial Catalog=Sandbox;Provider=SQLNCLI10.1;Integrated Security=SSPI;"/>
</Connections>
<Tables>
<Table Name="OrderHeader" ConnectionName="DbConnection">
<Columns>
<Column Name="OrderId" DataType="Int32" IdentityIncrement="1" IdentitySeed="1"/>
<Column Name="SalesDate" DataType="DateTime"/>
<Column Name="CustomerName" DataType="String" Length="50"/>
</Columns>
<Keys>
<PrimaryKey Name="OrderHeaderPK">
<Columns>
<Column ColumnName="OrderId"/>
</Columns>
</PrimaryKey>
</Keys>
</Table>
<Table Name="OrderDetail" ConnectionName="DbConnection">
<Columns>
<Column Name="OrderDetailId" DataType="Int32" IdentityIncrement="1" IdentitySeed="1"/>
<TableReference Name="OrderId" TableName="OrderHeader"/>
<Column Name="ProductName" DataType="String" Length="50"/>
<Column Name="Qty" DataType="Int16"/>
<Column Name="UnitPrice" DataType="Currency"/>
</Columns>
<Keys>
<PrimaryKey Name="OrderDetailPK">
<Columns>
<Column ColumnName="OrderDetailId"/>
</Columns>
</PrimaryKey>
</Keys>
</Table>
</Tables>
</Biml>
Tables are defined in a <Table> tag. They can have columns defined, as well as keys, and even indexes (not shown in the example above). Notice that the OrderId column doesn’t have a DataType attribute. Many of the attributes in Biml have default values, and data type is one of them. If it’s not specified, the column data type will default to Int32. The primary key for the table is defined with a <PrimaryKey> element.