Site Archives SQL

Recent blog posts about T4


July blogs posts about code generation with T4 text templates.

T4 template for generating SQL view from C# enumeration


Database tables often contain columns that store codes, or values with special meaning. In application code, these special values can be encapsulated as enumerations. This article demonstrates how to use T4 code generation templates and Visual Studio CodeModel API to generate SQL views that encapsulate the special values for use in SQL code.

How to generate multiple outputs from single T4 template


For some code generation tasks, like generating SELECT stored procedures based on indexes of a given database table, number of output artifacts may not be known upfront. Because T4 was designed to generate a single output file from one template file, developers are forced to generate multiple code artifacts in the same source file. This conflicts with the widely used practice of using one source file per code artifact. This article demonstrates how to work around this limitation of T4, generate multiple files from a single template and automatically add them to a Visual Studio project.

How to use T4 to generate CRUD stored procedures


This article demonstrates how to use SMO and T4 templates to generate CRUD stored procedures in Visual Studio and integrate them in a database project.

Refactoring Databases: Evolutionary Database Design by Scott Ambler and Pramod Sadalage


Today I am adding a new book to my shelf. It is Refactoring Databases: Evolutionary Database Design by Scott Ambler and Pramod Sadalage. This book extends the concept of refactoring to relational databases. Large enterprise databases are often accessed by multiple applications developed by different teams at different times and updated on different schedules. These […]