• Stars
    star
    157
  • Rank 237,526 (Top 5 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cross platform command line interface for SQL Server

sql-cli

Cross platform command line interface for SQL Server

NOTE: All Pull-Requests must be made into the dev branch.

Build Status

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-cli
cd sql-cli
git checkout dev
npm 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 for authentication
  -p, --pass <pass>              Password to use for authentication
  -o, --port <port>              Port to connect to
  -t, --timeout <timeout>        Connection timeout in ms
  -T, --requestTimeout <timeout> Request timeout in ms
  -d, --database <database>      Database to connect to
  -q, --query <query>            The query to execute
  -v, --tdsVersion <tdsVersion>  Version of tds protocol to use [7_4, 7_2, 7_3_A, 7_3_B, 7_4]
  -e, --encrypt                  Enable encryption
  -f, --format <format>          The format of output [table, csv, xml, json]
  -c, --config <path>            Read connection information from config file

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.0
Enter ".help" for usage hints.
mssql>

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 for a value of specific type (col|text)
.indexes TABLE      Lists all the indexes of a table                
.read FILENAME      Execute commands in a file                      
.run FILENAME       Execute the file as a sql script                
.schema TABLE       Shows the schema of a table                     
.analyze            Analyzes the database for missing indexes.      
.quit               Exit the cli

To get the list of databases use the '.databases' command

mssql> .databases
name
------------------
master
test

2 row(s) returned in 12 ms

To get the list of tables use the '.tables' command

mssql> use test;
OK
mssql> .tables
database  schema  name   type
--------  ------  -----  ----------
test      dbo     books  BASE TABLE
test      dbo     test   BASE TABLE

2 row(s) returned in 24 ms

To find all tables with a specified column name

mssql> .search col ID
Searching...
table_name                  schema_name  column_name     
--------------------------  -----------  ----------------
Customers                   dbo          ID     
Products                    dbo          ID
2 row(s) returned

Executed in 1 ms

To find all records in a database with a value

mssql> .search text john
Searching...
ColumnName                  ColumnValue    
--------------------------  -----------
[dbo].[Customers].[Name]    John             
[dbo].[Books].[Author]      John        
2 row(s) returned

Executed in 1 ms

To exit the cli use the '.quit' command

mssql> .quit

More Repositories

1

Squiggle

A free open source LAN Messenger
C#
110
star
2

trash-cleaner

A program to delete trash emails based on keyword and label filters.
JavaScript
93
star
3

SharePointLogViewer

SharePoint LogViewer - View ULS logs the easy and efficient way
C#
24
star
4

pyMVC

A Python Flask MVC web application framework
JavaScript
20
star
5

semantic-quran-web

Web UI for Semantic Quran App
JavaScript
15
star
6

tweet-deletor

A Chrome extension to delete all your tweets, likes and retweets from Twitter
JavaScript
13
star
7

RegExplore

Reg Explore - Registry editor written in C#
C#
8
star
8

RegExTestBed

A regular expression testing tool written in WinForms C#
C#
5
star
9

blendfilter

Blend filter and Pencil sketch effect in C#
C#
4
star
10

GillyMessenger

MSN clone written in VB6
Visual Basic
4
star
11

prayer-signup

A script to register for the prayer in the Bay Area
JavaScript
3
star
12

fb-post-deletor

A Chrome extension to delete all your Facebook posts from activity log page
JavaScript
3
star
13

semantic-quran-api

REST Api for Semantic Quran App
JavaScript
2
star
14

documentdb-cli

Cross platform command line interface for DocumentDB
JavaScript
2
star
15

mobile-services-dbinit

Database initializer for Azure Mobile Service
JavaScript
1
star
16

qruhma

C#
1
star
17

mobile-services-async-tasks

Extension for Azure Mobile Services for running asynchronous tasks in the background that are triggered by external events.
JavaScript
1
star
18

DraggerGame

Dragger - Sokoban clone written in C#
C#
1
star
19

MVVMPSample

Prism MVVMP Stub and Sample
C#
1
star
20

TwilioCon2013

1
star
21

LetsDonateStuff

LetsDonateStuff.com - Save earth and help others
C#
1
star