Start a system process in Biml with C#

If you’ve read my earlier post on how to use biml and output .sql files you might wanna take the DDL generation to the next level and deploy it straight away instead of handling files. The following example showcases how easy it is to create or recreate your development environment in SQL Server with Biml.

This example consists of 3 Biml files and assumes you already have collections defined inside RootNode.Tables.








The file functions as a CalleeBimlScript file. Note the property name=”tableNode” type=”AstTableNode”. This enables us to call this BimlScript file and when the script is running reference all properties from the Table collection.
Please feel free and visit Cathrine Wilhelmsens blog post and learn more about CallBimlScript.

This Biml file is actually optional and you can ignore if you’d like. The file is used for debug purposes to verify that the CalleeBimlScript correctly outputs the DDL definition.

This used to call SQLCMD on your computer and start a command line process with the arguments for the database you’d like to deploy to and the query you’d like to run.

And to break it down. We use the CallBimlScript function and output the DDL definition into a variably called “query”. Further on we’ve got a extension method called “StartProcess” that takes two inputs. The “application” path for the executable we’d like to call and a “args” that holds the argument we’d like to execute our application with.
For further information on how .Process works, feel free and look into the MSDN documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *