Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux cli tool to dump SQL Server schema to a text file

Do you know a reliable command line tool able to export SQL Server schema to a text file?

like image 407
cur4so Avatar asked Apr 27 '17 22:04

cur4so


People also ask

How do I export data from a text file in SQL Server?

Export SQL Server data by using the SQL Server Import and Export Wizard. The SQL Server Import and Export Wizard allowing users to copied data from and to data sources. This Wizard can be opened in two ways, through SQL Server Management Studio, or a stand-alone application through the Start menu.


1 Answers

You can do this with mssql-scripter. Download through - pip install mssql-scripter.

The command you'll want to use is along the lines of:

$ mssql-scripter -S serverName -d databaseName -U user > ./my-schema.sql 

The default is schema only (you can also specify --schema-and-data and --data-only). The command line will prompt for your password.

And you can pipe to stdout, sed, or a .sql file currently. Here's the GitHub page as this is an OSS repo - https://github.com/Microsoft/mssql-scripter. Please do file issues on the repo if you run into any.

like image 120
Tara Raj Avatar answered Oct 05 '22 03:10

Tara Raj