ScriptDB version: 2.0.0.0 Usage: ScriptDb.exe -con [-parameter1] [-parameter2] ... Parameters: -con: [-scriptAllDatabases] [-outDir:] | [-outFile: | -] [-noCreateDbDir] [-noCreateDbFile] [-tableOneFile] [-purge] [-verbose] [-data] [-filterDate:] [-noPauseIfError] [-table:table1, table2, ...] [-tableFile:] [-tableFileRegEx:] [-view:view1, view2, ...] [-viewFile:] [-viewFileRegEx:] [-sp:sp1, sp2, ...] [-spFile:] [-spFileRegEx:] [-rule:rule1, rule2, ...] [-ruleFile:] [-ruleFileRegEx:] [-default:default1, default2, ...] [-defaultFile:] [-defaultFileRegEx:] [-uddt:uddt1, uddt2, ...] [-uddtFile:] [-uddtFileRegEx:] [-udf:udf1, udf2, ...] [-udfFile:] [-udfFileRegEx:] [-udt:udt1, udt2, ...] [-udtFile:] [-udtFileRegEx:] [-ddlTrigger:ddlTrigger1, ddlTrigger, ...] [-ddlTriggerFile:] [-ddlTriggerFileRegEx:] [-noSchema] [-noAssemblies] [-noUddts] [-noUdts] [-noUdfs] [-noDefaults] [-noRules] [-Roles] [-noTables] [-noViews] [-noSPs] [-noFullTextCatalogs] [-noDdlTriggers] [-noEncrypted] [-sql2000] [-sql2005] [-sql2008] [-sql2008R2] [-sql20012] [-extendedProperties] [-permissions] [-drop] [-noCollation] [-includeDatabase] [-fileGroup] [-fillFactor] [-sortTableColumns] [-sortIndexColumns] [-defaultOrig] [-forReplication] [-withNoCheck] [-noSet] [-force_SET_QUOTED_IDENTIFIER_ON | -force_SET_QUOTED_IDENTIFIER_OFF] [-force_SET_ANSI_NULLS_ON | -force_SET_ANSI_NULLS_OFF] [-force_SET_ANSI_PADDING_ON | -force_SET_ANSI_PADDING_OFF] Note: System database objects are not scripted. -? | -help - Display help. -con: - A connection string to the database to be scripted. Required. If this paramter is empty (eg -con) ScriptDb will try to connect to the local database server and script the default user database to a file. -outDir: - Will script all database objects to this drirectory. -noCreateDbDir - If specified will not create a sub directory under outDir with the database name. If not specified the directory will be created. If scripting all user databases of a sql server, a subdirectory per database will always be created. If used, parameter -outDir must be used as well. -outFile:<|-> - Specify output filename. If file already exists, all output will be appended to the end of the file. All objects will be scripted in ONE file. Specify '-' to output to console. -noCreateDbFile - If specified will not add the database name to the outFile Eg: dbname_script.sql If -scriptAllDatabases this will create a script file per database found at the sql server. If used, parameter -outFile must be used as well. -tableOneFile - Write all scripts associated with a table into one file. Foreign Keys are not included in the same file becouse first all tables need to be created before we can create foreign keys. Will be ignored if -outFile is specified. -purge - Ensures output folder is emptied of all files before generating scripts when using -outDir. If using -outFile parameter, the specified output file will be deleted first. -scriptAllDatabases - Script all user databases on the current server. -data - Export data from tables to files using bcp. Will always create a file per table and create a subdirectory with name Data. -bcpCP: - Code page number to be used for bcp command when scripting data (-data paramter is used) If not specified, default 1252 is used. -verbose - For verbose output. It will show the names of all database objects scripted. [FILTER DATABASE OBJECTS OPTIONS] -table - Comma separated list of tables to script. EG: products, customers -tableFile: - File name storing the table filter list. -tableFileRegEx: - Reg expression to be used when loading table names from filter file. -view - Comma separated list of views to script. EG: view1, view2 -viewFile: - File name storing the view filter list. -viewFileRegEx: - Reg expression to be used when loading view names from filter file. -sp - Comma separated list of stored procedures to script. EG: spAddUser, spRemoveUser -spFile: - File name storing the stored procedures filter list. -spFileRegEx: - Reg expression to be used when loading stored procedures names from filter file. -rule - Comma separated list of rules to script. EG: rule1, rule2 -ruleFile: - File name storing the rules filter list. -ruleFileRegEx: - Reg expression to be used when loading rule names from filter file. -default - Comma separated list of defaults to script. EG: default1, default2 -defaultFile: - File name storing the defaults filter list. -defaultFileRegEx: - Reg expression to be used when loading default names from filter file. -uddt - Comma separated list of user defined data types to script. EG: uddt1, uddt2 -uddtFile: - File name storing the user defined data types filter list. -uddtFileRegEx: - Reg expression to be used when loading user defined data type names from filter file. -udf - Comma separated list of user defined functions to script. EG: udf1, udf2 -udfFile: - File name storing the user defined functions filter list. -udfFileRegEx: - Reg expression to be used when loading user defined function names from filter file. -udt - Comma separated list of user defined types to script. EG: udt1, udt2 -udtFile: - File name storing the user defined functions filter list. -udtFileRegEx: - Reg expression to be used when loading user defined function names from filter file. -ddlTrigger - Comma separated list of ddl triggers to script. EG: ddlTrigger1, ddlTrigger2 -ddlTriggerFile: - File name storing the ddl triggers filter list. -ddlTriggerFileRegEx: - Reg expression to be used when loading ddl triggers names from filter file. [OPTIONS FOR SCRIPTS GENERATION] -sql2000 - Generate SQL 2000 compatible scripts. -sql2005 - Generate SQL 2005 compatible scripts. -sql2008 - Generate SQL 2008 compatible scripts. -sql2008R2 - Generate SQL 2008R2 compatible scripts. -sql2012 - Generate SQL 2012 compatible scripts. NOTE: If none of the sql???? paramters is used, the sql scripts will be generated following the sql version of the sql server. -extendedProperties - Script extended properties for each object. -permissions - Script permissions for all database objects. For user defined functions only permissions of type References, Execute and Select are included becouse only these are supported. -noCollation - No not include collation in the scripts. -includeDatabase - Include database context in scripted objects. -drop - Generate DROP statements. By default drop statements are not generated. -filterDate: - Specify to script only objects modified after the supplied date and time. Only two string formats are allowed for date and time: yyyyMMdd and yyyyMMdd_HHmm (i.e. 20091112 or 20091112_1450 ) Note: this feature is not supported on SQL 2000. -noPauseIfError - Do not wait for user imput when encountering an error. This parameter is usefull when executing the ScriptDb from a job or task. -noSchema - Do not script schema's. -noAssemblies - Do not script assemblies. -noUddts - Do not script user defined data types. -noUdts - Do not script user defined types. -noUdfs - Do not script user defined functions. -noDefaults - Do not script defaults. -noRules - Do not script rules. -Roles - Script roles. -noTables - Do not script tables, including indexes. -noViews - Do not script views. -noSPs - Do not script stored procedures. -noFullTextCatalogs - Do not script full text catalogs. -noDdlTriggers - Do not script DDL triggers. -fileGroup - Include file group information when scripting tables. -fillFactor - Include fill factor information when scripting indexes. -sortTableColumns - When scripting table definitions, sort colums by name, ascending. This can be used when comparing database structures and ignoring column order is required. -sortIndexColumns - When scripting non clustered index definitions, sort index key colums and included columns, by name, ascending. This can be used when comparing database structures and ignoring column order is required. -defaultOrig - Include original default values, as for example ((0)). Without this parameter the default values will be patched to remove the unnecessary pharanteses () around the values. EG: ((0)) --> (0). -noEncrypted - Do not script encrypted database objects. Without this parameter all database objects, including encrypted ones, are scripted. -noSet - Do not Include SET ANSI_PADDING, SET QUOTED_IDENTIFIER and SET ANSI_NULLS statements. -force_SET_QUOTED_IDENTIFIER_ON | -force_SET_QUOTED_IDENTIFIER_OFF Will be ignored if -noSet is used. -force_SET_ANSI_NULLS_ON | -force_SET_ANSI_NULLS_OFF Will be ignored if -noSet is used. -force_SET_ANSI_PADDING_ON | -force_SET_ANSI_PADDING_OFF Will be ignored if -noSet is used. -forReplication - Include NOT FOR REPLICATION clause for table fields(columns). and Foreign keys and Check Constraints. -withNoCheck - Always script the create statement of check constraints and foreign keys using WITH NOCHECK statement. If specified the {Check Existing Data on Creation or Re-Enabling} property of the constraint will always be scripted as false. Examples: 1. Script database pubs to file [pubs.sql]: ScriptDb.exe -con:server=(local);database=pubs;trusted_connection=yes Note: Database structure will be scripted and appended to output file pubs.sql, therefore, as a result, so if you execute the same command multiple times, the output file will grow and grow. 2. Script database pubs to file [pubs.sql] and delete the output file first: ScriptDb.exe -con:server=(local);database=pubs;trusted_connection=yes -purge 3. Script database pubs to directory [Scripts\pubs] and clean up existing sql files first: ScriptDb.exe -con:server=(local);database=pubs;trusted_connection=yes -outDir:Scripts -purge 4. Script all user databases from local sql server to files (one per database, dbname.sql) and delete the existing output files first: ScriptDb.exe -con:server=(local);database=pubs;trusted_connection=yes -purge -scriptAllDatabases