Use GetTableSql() to Generate CREATE TABLE Scripts
Builds a 'Create Tables' SSIS package with one ExecuteSQL task for every 'Table', 'Dimension', and 'Fact' in the Biml model. Each task uses the matching object's 'Connection' as the target and 'GetTableSql()' as the DirectInput, so running the generated package issues 'CREATE TABLE' DDL against the destination database in a single linear pass.
The Biml model objects can come from hand-authored Biml files, from a 'BimlScript' that imported an existing database, or from any other source that lives in 'RootNode'. The template declares 'tier="2"' so it runs after lower-tier scripts that populate the model. In BimlExpress, compile this file together with the file or files that define the tables.
<#@ template language="C#" tier="2" #>
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Packages>
<Package Name="Create Tables" AutoCreateConfigurationsType="None" ConstraintMode="Linear">
<Tasks>
<# foreach(var table in RootNode.Tables) {#>
<ExecuteSQL Name="Create <#=table.Name#>" ConnectionName="<#=table.Connection.Name#>">
<DirectInput>
<#=table.GetTableSql()#>
</DirectInput>
</ExecuteSQL>
<# } #>
<# foreach(var table in RootNode.Dimensions) {#>
<ExecuteSQL Name="Create <#=table.Name#>" ConnectionName="<#=table.Connection.Name#>">
<DirectInput>
<#=table.GetTableSql()#>
</DirectInput>
</ExecuteSQL>
<# } #>
<# foreach(var table in RootNode.Facts) {#>
<ExecuteSQL Name="Create <#=table.Name#>" ConnectionName="<#=table.Connection.Name#>">
<DirectInput>
<#=table.GetTableSql()#>
</DirectInput>
</ExecuteSQL>
<# } #>
</Tasks>
</Package>
</Packages>
</Biml>