다음을 통해 공유


Azure SQL Database: SQLCMD and BCP on Ubuntu Linux

Azure SQL Database abstracts the underlying operating system from the developer.  To the developer, this means that they have access to a database via a TDS connection but have no access to the underlying operation system.  The Azure SQL Database could be running on Ubuntu or Minix and the developer would not know the difference (spoiler alert, Azure SQL Database runs on Windows). 

While its true that developers do not have to worry about the underlying operating system of Azure SQL Database, they certainly do have to worry about their application operating system.  With greater than 20% of the VMs in Azure running Linux [link] and the popularity of Azure SQL Database, the SQL Database naturally gets many questions on how to connect to and manager Azure SQL Database from non-Windows platforms.  This blog will kick-off a series of articles and tutorials on how to do just that.

For Linux, the most natural place to start is with the Linux command line. In this blog we will install (and use) the quintessential SQL Server/SQL Database command line tools on Linux: SQLCMD and BCP.  For this tutorial, we’ll use Ubuntu 14.04 LTS as it is the least common denominator for the many flavors of Linux between developers and cloud providers.  

If you want to keep up to date with Azure SQL Database, follow us on Twitter (@AzureSQLDB). If you have questions, please ask us on [Stack Overflow] or [MSDN].

Prerequisites:

  • Ubuntu 14.04 machine whether it is on your laptop, dev machine, in Azure [link], or another cloud provider
  • Access to an Azure SQL Database [link] or SQL Server (Express [link])

Download the install script [ source ]:

 wget https://gallery.technet.microsoft.com/scriptcenter/SQLCMD-and-BCP-for-Ubuntu-c88a28cc/file/142121/1/Ubuntu%2014.04%20MSFT%20ODBC%20Driver.sh

Install the SQLCMD, BCP and the Linux ODBC driver (execute the script from your user directory i.e, /home/nickfury/)

 sudo bash Ubuntu\ 14.04\ MSFT\ ODBC\ Driver.sh 

Connect to Azure SQL Database (similar for SQL Server)

 sqlcmd –S yourServerName.database.windows.net – U yourUsername – P yourPassword
 

Execute a command:

  1> Select @@version;
 2> Go

For more information:

For questions: