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.

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
  • find string literals used in TSQL code
  • find strings in TSQL modules
  • display object dependencies
  • check objects
  • list data diagrams, and tables in data diagrams
  • optionally (-td) split CREATE TABLE into table and table details scripts
  • filter operations by object names

Resulting scripts 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.