Automate Scripting with SQL Scripter

,

SQL Scripter is an open-source console tool for generating SQL Server DDL. Written in C# using .NET 2.0, SQL Scripter provides front-ends for MSBuild, NAnt and the Windows command line. Each front end supports syntax for specifying which types of database objects to script, including all objects of a type or directly named instances.

SQL Scripter supports interaction with build scripts written for MSBuild. MSBuild is a command line build tool introduced with Microsoft Visual Studio 2005. MSBuild is also an integral part of Microsoft’s Team Foundation System (TFS) build development and revision control system. It has a specific XML dialect where targets can execute built-in or custom tasks. SQL Scripter front-end support for MSBuild come via the custom task facilities and accepts standard item group syntax as well as custom attributes to control schema generation over a range of SQL object types and instances.

The XML listing provided here is a complete MSBuild built script example with tables, procedures, functions, UDFs, and XML schemas.

Possible applications for SQL Scripter include deployment into an automated build process to support continuous integration. SQL Scripter can be used to generate DDL of the latest developer database schema.

The full source and runtime binaries for SQL Scripter can be found at http://www.codeplex.com/SQLScripter/.

<Project DefaultTargets="Script" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	<UsingTask AssemblyFile="SQLScripter.MSBuild.Task.dll" TaskName="SQLScripter" />

	<ItemGroup>
		<XSDSchemas Include="ALL" />
		<Tables Include="ALL" />
		<Views Include="ALL" />
		<Functions Include="ALL" />
                <Rules Include="ALL" />
	</ItemGroup>

	<Target Name="Script">
		<SQLScripter ServerName="localhost" DatabaseName="LocalTestDB" Tables="@(Tables)" Procedures="@(Procedures)" UserDefinedFunctions="@(Functions)" XSDSChemas="@(XSDSchemas)" OutputFile="TestDB.sql" />
	</Target>

</Project>

Rate

3.33 (3)

Share

Share

Rate

3.33 (3)