Hosting » Azure » How do I connect to an Azure SQL Database?

How do I connect to an Azure SQL Database?

Last updated on December 16, 2022 @ 1:26 pm

SQL Server is a relational database management system (RDBMS), supporting the Structured Query Language (SQL). SQL Server is Microsoft’s most popular relational database, used in a wide range of applications, from small business to large enterprise. Azure SQL Database is Microsoft’s cloud-based version of SQL Server, supporting the same features and functionality as the on-premises product.

Azure SQL Database is available in two tiers: Basic and Standard. Basic offers unlimited storage, while Standard offers a lower limit of 1TB. .

1. To connect to an Azure SQL Database, first create a connection string using the az provider command. The connection string can be found in the Azure portal under the Databases section.

2. The following example connects to the Northwind sample database in the default instance of the SQL Server instance in the West US region.

CREATE CONNECTION [sqlserver]

name = N’sqlserver’,

type = ‘Azure SQL Database’,

subscriptionId = ”,

location = ‘WUSA’,

serverName = N’SQL Server’,

datacenter = ‘WestUS’,

provider = ‘Microsoft.SQLServer.Server’)

3. After creating the connection string, use the connection object to connect to the database. The connection object can be found in the Azure portal under the Connections section.

PRO TIP: When connecting to an Azure SQL Database, be sure to use the correct server name. The server name should be in the format of .database.windows.net. If you use the wrong server name, you will receive an error message.

4. The following example connects to the Northwind sample database and prints the connection string.

SELECT connectionString

FROM AzureSQLConnection

5. The connection string can also be used to connect to the database using the SQL Server Management Studio. The connection string can be found in the Connections section of the Server Properties dialog box.

Kathy McFarland

Kathy McFarland

Devops woman in trade, tech explorer and problem navigator.