sql-cli
Cross platform command line interface for SQL Server
NOTE: All Pull-Requests must be made into the dev
branch.
Installation
You can install the sql-cli npm package.
npm install -g sql-cli
If you're more adventurous and like to live on the edge then you can install development version as follows:
git clone https://github.com/hasankhan/sql-clicd sql-cligit checkout devnpm install -g
Get Started
To get the list of all parameters type 'mssql -h'
Usage: mssql [options] Options: -h, --help output usage information -V, --version output the version number -s, --server <server> Server to connect to -u, --user <user> User name to use
To connect to a SQL Server instance in Azure invoke mssql as follows
mssql -s abcdef.database.windows.net -u username@abcdef -p thepassword -d mydatabase -e
You will get a prompt as follows:
Connecting to abcdef.database.windows.net...done sql-cli version 0.1.0Enter ".help"
To get the list of all commands use the '.help' command
mssql> .help.help Shows this message .databases Lists all the databases .tables Lists all the tables .sprocs Lists all the stored procedures .search TYPE VALUE Searches
To get the list of databases use the '.databases' command
mssql> .databasesname------------------mastertest 2 row returned in 12 ms
To get the list of tables use the '.tables' command
mssql> use test;OKmssql> .tablesdatabase schema name type-------- ------ ----- ----------test dbo books BASE TABLEtest dbo test BASE TABLE 2 row returned in 24 ms
To find all tables with a specified column name
mssql> .search col IDSearching...table_name schema_name column_name -------------------------- ----------- ----------------Customers dbo ID Products dbo ID2 row returned Executed in 1 ms
To find all records in a database with a value
mssql> .search text johnSearching...ColumnName ColumnValue -------------------------- -----------[dbo].[Customers].[Name] John [dbo].[Books].[Author] John 2 row returned Executed in 1 ms
To exit the cli use the '.quit' command
mssql> .quit