{"id":20416,"date":"2017-05-16T09:00:00","date_gmt":"2017-05-16T16:00:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/dataplatforminsider\/?p=20416"},"modified":"2024-01-22T22:50:58","modified_gmt":"2024-01-23T06:50:58","slug":"sql-server-command-line-tools-for-macos-released","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2017\/05\/16\/sql-server-command-line-tools-for-macos-released\/","title":{"rendered":"SQL Server Command Line Tools for macOS released"},"content":{"rendered":"
This post was authored by Meet Bhagdev, Program Manager, Microsoft<\/em><\/p>\n 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.<\/p>\n The sqlcmd utility<\/a> 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.<\/p>\n The bulk copy program utility (bcp)<\/a> 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.<\/p>\n For more information, check out some examples for sqlcmd<\/a> and bcp<\/a>.<\/p>\n Please file bugs, questions or issues on our Issues <\/a>page. We welcome contributions, questions and issues of any kind.<\/p>\nInstall the tools for macOS El Capitan and Sierra<\/h2>\n
\/usr\/bin\/ruby -e \u201c$(curl - <\/span>fsSL <\/span>https:\/\/raw.githubusercontent.com\/Homebrew\/install\/master\/install)\u201d<\/span>\r\n brew tap microsoft\/mssql-release<\/span>\u00a0<\/span>https:\/\/github.com\/Microsoft\/homebrew-mssql-release<\/a>\r\n brew update\r\n brew install --no-sandbox msodbcsql mssql-tools\r\n #for silent install ACCEPT_EULA=y brew install --no-sandbox msodbcsql mssql-tools<\/span><\/pre>\nGet started<\/h2>\n
SQLCMD\r\n <\/strong>sqlcmd -S localhost -U sa -P <your_password> -Q \u201c<your_query>\u201d <\/span><\/span><\/pre>\nBCP<\/strong>\r\n <\/span>bcp <your table>in ~\/test_data.txt -S localhost -U sa -P <your password>-d<your database> -c -t \u2018,\u2019\r\n bcp <your table>out ~\/test_export.txt -S localhost -U sa -P<your password> -d<your database> -c -t \u2018,\u2019<\/span> <\/span><\/pre>\n