Project Description

The ScriptDB utility lets you script all or a subset of SQL Server databases on a server. It gives the same output as the script database facility in SQL Server Management Studio with the added benefit of being able to script multiple databases in a single execution. Scripts are compliant with the options mentioned in http://support.microsoft.com/kb/914288.

Prerequisites

The databases being scripted must reside on SQL Server 2008 or above.
The machine where ScriptDB is running on must have the SMO library that ships with SQL Server 2008 or above and .NET Framework 3.5 or above.

Instructions

ScriptDB is a command line tool. A minimal command line is shown below:

ScriptDB.exe -S SQL Server Name -U username -P password

Note the following about the command line:
  1. The switches are case sensitive.
  2. There must be a space after the switch.
  3. The order of the switches does not matter.
  4. To connect with Windows Authentication, do not specify -U and -P

Scripting a subset of databases

The -Q switch allows you to select the databases to script using a partial query. The partial query consists of a 'WHERE name' clause followed by the filter. The example below will script all databases beginning with az

ScriptDB.exe -S SQL Server Name -U username -P password -Q "WHERE name LIKE '%az%';"

More information
  1. For troubleshooting purposes, ScriptDB creates a log file named ScriptDBApp.trace located in the application's directory.
  2. Scripting functionality is totally contained withing SqlScripterEngine.dll so you can create your own host if the console application does not meet your requirements.

Last edited Sep 28, 2011 at 7:29 PM by farooqam, version 2