WiltonDB Schema Export command‐line tool - wiltondb/wiltondb GitHub Wiki
On this page:
Prerequisites
Schema Export tool overview
wdb_schema.exe is a command-line tool that can export DB schema from MSSQL. It is based on the same DB-introspection framework that is used by SSMS for exporting schema from GUI.
wdb_schema.exe
can export either a single specified table definition, or all the objects from the specified DB.
Usage:
wdb_schema.exe --help
wdb_schema 1.0.0+aa4a6f20547096933362eb4f1034fa4bd5e1c559
WiltonDB Software
-s, --hostname Required. Specifies the hostname of the DB to which to connect.
-p, --port Specifies the TCP port of the DB to which to connect.
-n, --instance Specifies the instance name of SQL Server to which to connect.
-u, --username Specifies the login name used to connect to DB.
-x, --password Specifies the password for the login ID. If this option isn't used, the
password is read from WDBSCHEMAPASSWORD environment variable.
-w, --windows_auth Specifies that the tool connects to DB with a trusted connection using
integrated security.
-d, --database Required. Specifies the database to connect to.
-t, --table Specifies the table name to export the schema only for this table.
-h, --table_schema Specifies the table schema name to export the schema only for this table.
-f, --functions Specifies that the functions and stored procedures must be included into the
exported schema.
--help Display this help screen.
--version Display version information.
Export examples
Export single table connecting to MSSQL on specified port by username and password:
wdb_schema.exe -s 127.0.0.1 -p 6433 -u mylogin -x mypwd -d test1 -t tab1
Export single table connecting to a named MSSQL instance:
wdb_schema.exe -s DESKTOP-JS80C9O -n SQLEXPRESS -u mylogin -x mypwd -d test1 -t tab1
Export single table connecting to MSSQL specifying password in environment variable:
set WDBSCHEMAPASSWORD=mypwd
wdb_schema.exe -s DESKTOP-JS80C9O -n SQLEXPRESS -u mylogin -d test1 -t tab1
Export single table connecting to MSSQL using Windows Authentication:
wdb_schema.exe -s DESKTOP-JS80C9O -n SQLEXPRESS -w -d test1 -t tab1
Export schema redirecting output to a file:
wdb_schema.exe -s DESKTOP-JS80C9O -n SQLEXPRESS -w -d test1 -t tab1 > tab1.sql
Export all objects from the specified database (may take a long time):
wdb_schema.exe -s DESKTOP-JS80C9O -n SQLEXPRESS -w -d test1
Next: Data import with sqlcmd