SQL Server Command Line Tools for macOS released

By SQL Server Team

This post was authored by Meet Bhagdev, Program Manager, Microsoft

We are delighted to share the production-ready release of the SQL Server Command Line Tools (sqlcmd and bcp) on macOS El Capitan and Sierra.

The sqlcmd utility is a command-line tool that lets you submit T-SQL statements or batches to local and remote instances of SQL Server. The utility is extremely useful for repetitive database tasks such as batch processing or unit testing.

The bulk copy program utility (bcp) bulk copies data between an instance of Microsoft SQL Server and a data file in a user-specified format. The bcp utility can be used to import large numbers of new rows into SQL Server tables or to export data out of tables into data files.

Install the tools for macOS El Capitan and Sierra

/usr/bin/ruby -e “$(curl – fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install mssql-tools
#for silent install ACCEPT_EULA=y brew install mssql-tools

Get started

sqlcmd -S localhost -U sa -P -Q “

bcp in ~/test_data.txt -S localhost -U sa -P -d -c -t ‘,’
bcp out ~/test_export.txt -S localhost -U sa -P -d -c -t ‘,’

For more information, check out some examples for sqlcmd and bcp.

Please file bugs, questions or issues on our Issues page. We welcome contributions, questions and issues of any kind.

Source:: Microsoft – SQL Server