Microsoft SQL Server Client 2017 on Debian 9
- Databases and storage
- Published
- 2 min read
- @nabbisen
As is a way to install the server of Microsoft (opens in a new tab) SQL Server 2017 (opens in a new tab), we can install the client called sqlcmd (opens in a new tab), a command line tool, as a part of mssql-tools (opens in a new tab) on Debian (opens in a new tab).
The installation is simple:
$ curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
$ sudo apt update
$ sudo apt install mssql-tools
That’s all. Then it is available:
$ /opt/mssql-tools/bin/sqlcmd
Of course, you can add /opt/mssql-tools/bin to your PATH environment variable.
The usage is like this:
$ /opt/mssql-tools/bin/sqlcmd
Microsoft (R) SQL Server Command Line Tool
Version 17.3.0000.1 Linux
Copyright (c) 2012 Microsoft. All rights reserved.
usage: sqlcmd [-U login id] [-P password]
[-S server or Dsn if -D is provided]
[-H hostname] [-E trusted connection]
[-N Encrypt Connection][-C Trust Server Certificate]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w screen width]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-c cmdend]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
[-u unicode output] [-r[0|1] msgs to stderr]
[-i inputfile] [-o outputfile]
[-k[1|2] remove[replace] control characters]
[-y variable length type display width]
[-Y fixed length type display width]
[-p[1] print statistics[colon format]]
[-R use client regional setting]
[-K application intent]
[-M multisubnet failover]
[-b On error batch abort]
[-D Dsn flag, indicate -S is Dsn]
[-X[1] disable commands, startup script, environment variables [and exit]]
[-x disable variable substitution]
[-? show syntax summary]
For example, you can execute a SQL file this way:
$ /opt/mssql-tools/bin/sqlcmd -H <db-host> -d <database> -U <db-user> -i ./xxx.sql
$ # You will be asked about <db-password>.
If your locale is NOT English, check it before running.
Thank you for your reading :) Happy computing.
More on: Run a database on your server
-
MariaDB is one of the most popular relational database management systems (RDBMS), forked from MySQL by some of the original developers.
-
OpenBSD gives us good documentation as a series of the project.
-
OpenBSD gives us good documentation as a series of the project.
Scqr [secureal]
Scqr [secureal]: the engineering practice of Reflerd Inc. (opens in a new tab)
Comments and feedback are welcome.