2018/05/19
はじめに
sqlcmdは、簡単に言うとCLIのSQL Serverクライアントです。
macOSでもsqlcmdを入れることで、CLIでSQL Serverにつなげて、クエリを実行することができます。
GitHub
https://github.com/Microsoft/homebrew-mssql-release
インストール方法
brewでインストールできます
まとめ
1 2 3 4 |
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release brew update brew install --no-sandbox mssql-tools |
実行例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$ brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> Updated Formulae coreos-ct opensc wireguard-go fn txr wireguard-tools ==> Tapping microsoft/mssql-release Cloning into '/usr/local/Homebrew/Library/Taps/microsoft/homebrew-mssql-release'... remote: Counting objects: 18, done. remote: Compressing objects: 100% (11/11), done. remote: Total 18 (delta 8), reused 11 (delta 4), pack-reused 0 Unpacking objects: 100% (18/18), done. Tapped 10 formulae (54 files, 61.3KB) |
1 2 3 |
$ brew update Already up-to-date. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
brew install --no-sandbox mssql-tools ==> Installing mssql-tools from microsoft/mssql-release ==> Installing dependencies for microsoft/mssql-release/mssql-tools: libtool, unixodbc, openssl, msodbcsql17 ==> Installing microsoft/mssql-release/mssql-tools dependency: libtool ==> Downloading https://homebrew.bintray.com/bottles/libtool-2.4.6_1.high_sierra ######################################################################## 100.0% ==> Pouring libtool-2.4.6_1.high_sierra.bottle.tar.gz ==> Caveats In order to prevent conflicts with Apple's own libtool we have prepended a "g" so, you have instead: glibtool and glibtoolize. ==> Summary ? /usr/local/Cellar/libtool/2.4.6_1: 71 files, 3.7MB ==> Installing microsoft/mssql-release/mssql-tools dependency: unixodbc ==> Downloading https://homebrew.bintray.com/bottles/unixodbc-2.3.6.high_sierra. ######################################################################## 100.0% ==> Pouring unixodbc-2.3.6.high_sierra.bottle.tar.gz ? /usr/local/Cellar/unixodbc/2.3.6: 46 files, 1.8MB ==> Installing microsoft/mssql-release/mssql-tools dependency: openssl ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_1.high_sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring openssl-1.0.2o_1.high_sierra.bottle.tar.gz ==> Caveats A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash This formula is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile For compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include ==> Summary ? /usr/local/Cellar/openssl/1.0.2o_1: 1,791 files, 12.3MB ==> Installing microsoft/mssql-release/mssql-tools dependency: msodbcsql17 ==> Downloading https://download.microsoft.com/download/1/9/A/19AF548A-6DD3-4B48-88DC-724E9ABCEB9A/msodbcsql-17.1.0.1.tar.gz ######################################################################## 100.0% The license terms for this product can be downloaded from https://aka.ms/odbc170eula and found in /usr/local/share/doc/msodbcsql17/LICENSE.txt . By entering 'YES', you indicate that you accept the license terms. Do you accept the license terms? (Enter YES or NO) YES ==> odbcinst -u -d -n "ODBC Driver 17 for SQL Server" ==> odbcinst -i -d -f ./odbcinst.ini ==> Caveats If you installed this formula with the registration option (default), you'll need to manually remove [ODBC Driver 17 for SQL Server] section from odbcinst.ini after the formula is uninstalled. This can be done by executing the following command: odbcinst -u -d -n "ODBC Driver 17 for SQL Server" ==> Summary ? /usr/local/Cellar/msodbcsql17/17.1.0.1: 9 files, 2.7MB, built in 23 seconds ==> Installing microsoft/mssql-release/mssql-tools ==> Downloading https://download.microsoft.com/download/F/D/1/FD16AA69-F27D-440E-A15A-6C521A1972E6/mssql-tools-17.1.0.1.tar.g ######################################################################## 100.0% The license terms for this product can be downloaded from http://go.microsoft.com/fwlink/?LinkId=746949 and found in /usr/local/share/doc/mssql-tools/LICENSE.txt . By entering 'YES', you indicate that you accept the license terms. Do you accept the license terms? (Enter YES or NO) YES ? /usr/local/Cellar/mssql-tools/17.1.0.1: 11 files, 1.2MB, built in 11 seconds |
SQL Server 関連の参考文献
絵で見てわかるSQL Serverの内部構造 (DB Magazine Selection)
- 平山 理
- 価格 ¥ 2,700
- 販売者 Amazon.co.jp