Preview for SQL Server Command Line Tools for Mac now available

Preview for SQL Server Command Line Tools for Mac now available. 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 Mac El Capitan and Sierra

/usr/bin/ruby -e “$(curl -fsSL”
 brew tap microsoft/mssql-preview
 brew update
 brew install mssql-tools
 #for silent install ACCEPT_EULA=y brew install mssql-tools


 sqlcmd -S localhost -U sa -P <your_password> -Q “<your_query>”

 bcp TestEmployees in ~/test_data.txt -S localhost -U sa -P <your_password> -d BcpSampleDB -c -t ‘,’
 bcp <your_table> out ~/test_export.txt -S localhost -U sa -P <your_password> -d <yourdatabase -c -t ‘,’

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

You might also like

Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More