SMOscript

SQL Server 2000 provides a tool called scptxfr which generates DROP and CREATE scripts for all objects in a database.

Since it is not included in the latest SQL Server versions, I developed a replacement for scptxfr which uses the .Net SMO libraries for script generation called SMOscript:


smoscript 0.16.3665.39354 (c) by devio.at 2008-2010

list and script databases and database objects.

usage: smoscript [options] [command]

options: (leading '-' or '/')

-s server server name
-d database database name
-o [schema.]object object name
-u username username (default: integrated authentication)
-p password password (if -u is missing, password for sa)

-r generate DROP statements
-i include IF NOT EXISTS statements

-f filename output to file
-F directory output to directory

-A current ANSI codepage
-O ASCII
-T Unicode
-U UTF8

commands:

l list databases on server (implied by -s)
list objects in database (implied by -s -d)
s script all objects (implied by -s -d -F/-f)
script single object (implied by -s -d -o)
db list database properties

commands:

l list
s script object/s
db list database properties

list databases on server (implied by -s)
list objects in database (implied by -s -d)
script all objects (implied by -s -d -F/-f)

The SMOscript utility implements the following functions:

  • list all databases on a server
  • list all scriptable objects in a database
  • script CREATE or DROP statements for each object in database

Resulting script are either written to a single file, or to a separate file for each object. Table scripts will include child objects such as constraints and triggers.

Command line switches were selected to be compatible with scptxfr, but support both “-” and “/” as switch marker.

devioblog describes the latest changes to SMOscript here. SMOscript is available for download here.

Last Updated on Thursday, 14 January 2010 07:49
 
devio IT Services, Powered by Joomla! and designed by SiteGround web hosting