How to Query Azure Sql Database
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
- Feedback
- Edit
Azure SQL Database and Azure SQL Managed Instance connect and query articles
- Article
- 5 minutes to read
Thank you.
APPLIES TO: Azure SQL Database Azure SQL Managed Instance
The following document includes links to Azure examples showing how to connect and query Azure SQL Database and Azure SQL Managed Instance. For some related recommendations for Transport Level Security, see TLS considerations for database connectivity.
Quickstarts
Quickstart | Description |
---|---|
SQL Server Management Studio | This quickstart demonstrates how to use SSMS to connect to a database, and then use Transact-SQL statements to query, insert, update, and delete data in the database. |
Azure Data Studio | This quickstart demonstrates how to use Azure Data Studio to connect to a database, and then use Transact-SQL (T-SQL) statements to create the TutorialDB used in Azure Data Studio tutorials. |
Azure portal | This quickstart demonstrates how to use the Query editor to connect to a database (Azure SQL Database only), and then use Transact-SQL statements to query, insert, update, and delete data in the database. |
Visual Studio Code | This quickstart demonstrates how to use Visual Studio Code to connect to a database, and then use Transact-SQL statements to query, insert, update, and delete data in the database. |
.NET with Visual Studio | This quickstart demonstrates how to use the .NET framework to create a C# program with Visual Studio to connect to a database and use Transact-SQL statements to query data. |
.NET core | This quickstart demonstrates how to use .NET Core on Windows/Linux/macOS to create a C# program to connect to a database and use Transact-SQL statements to query data. |
Go | This quickstart demonstrates how to use Go to connect to a database. Transact-SQL statements to query and modify data are also demonstrated. |
Java | This quickstart demonstrates how to use Java to connect to a database and then use Transact-SQL statements to query data. |
Node.js | This quickstart demonstrates how to use Node.js to create a program to connect to a database and use Transact-SQL statements to query data. |
PHP | This quickstart demonstrates how to use PHP to create a program to connect to a database and use Transact-SQL statements to query data. |
Python | This quickstart demonstrates how to use Python to connect to a database and use Transact-SQL statements to query data. |
Ruby | This quickstart demonstrates how to use Ruby to create a program to connect to a database and use Transact-SQL statements to query data. |
Get server connection information
Get the connection information you need to connect to the database in Azure SQL Database. You'll need the fully qualified server name or host name, database name, and login information for the upcoming procedures.
-
Sign in to the Azure portal.
-
Navigate to the SQL Databases or SQL Managed Instances page.
-
On the Overview page, review the fully qualified server name next to Server name for the database in Azure SQL Database or the fully qualified server name (or IP address) next to Host for an Azure SQL Managed Instance or SQL Server on Azure VM. To copy the server name or host name, hover over it and select the Copy icon.
Get ADO.NET connection information (optional - SQL Database only)
-
Navigate to the database blade in the Azure portal and, under Settings, select Connection strings.
-
Review the complete ADO.NET connection string.
-
Copy the ADO.NET connection string if you intend to use it.
TLS considerations for database connectivity
Transport Layer Security (TLS) is used by all drivers that Microsoft supplies or supports for connecting to databases in Azure SQL Database or Azure SQL Managed Instance. No special configuration is necessary. For all connections to a SQL Server instance, a database in Azure SQL Database, or an instance of Azure SQL Managed Instance, we recommend that all applications set the following configurations, or their equivalents:
- Encrypt = On
- TrustServerCertificate = Off
Some systems use different yet equivalent keywords for those configuration keywords. These configurations ensure that the client driver verifies the identity of the TLS certificate received from the server.
We also recommend that you disable TLS 1.1 and 1.0 on the client if you need to comply with Payment Card Industry - Data Security Standard (PCI-DSS).
Non-Microsoft drivers might not use TLS by default. This can be a factor when connecting to Azure SQL Database or Azure SQL Managed Instance. Applications with embedded drivers might not allow you to control these connection settings. We recommend that you examine the security of such drivers and applications before using them on systems that interact with sensitive data.
Drivers
The following minimal versions of the tools and drivers are recommended if you want to connect to Azure SQL database:
Driver/tool | Version |
---|---|
.NET Framework | 4.6.1 (or .NET Core) |
ODBC driver | v17 |
PHP driver | 5.2.0 |
JDBC driver | 6.4.0 |
Node.js driver | 2.1.1 |
OLEDB driver | 18.0.2.0 |
SMO | 150 or higher |
Libraries
You can use various libraries and frameworks to connect to Azure SQL Database or Azure SQL Managed Instance. Check out our Get started tutorials to quickly get started with programming languages such as C#, Java, Node.js, PHP, and Python. Then build an app by using SQL Server on Linux or Windows or Docker on macOS.
The following table lists connectivity libraries or drivers that client applications can use from a variety of languages to connect to and use SQL Server running on-premises or in the cloud. You can use them on Linux, Windows, or Docker and use them to connect to Azure SQL Database, Azure SQL Managed Instance, and Azure Synapse Analytics.
Language | Platform | Additional resources | Download | Get started |
---|---|---|---|---|
C# | Windows, Linux, macOS | Microsoft ADO.NET for SQL Server | Download | Get started |
Java | Windows, Linux, macOS | Microsoft JDBC driver for SQL Server | Download | Get started |
PHP | Windows, Linux, macOS | PHP SQL driver for SQL Server | Download | Get started |
Node.js | Windows, Linux, macOS | Node.js driver for SQL Server | Install | Get started |
Python | Windows, Linux, macOS | Python SQL driver | Install choices: * pymssql * pyodbc | Get started |
Ruby | Windows, Linux, macOS | Ruby driver for SQL Server | Install | Get started |
C++ | Windows, Linux, macOS | Microsoft ODBC driver for SQL Server | Download |
Data-access frameworks
The following table lists examples of object-relational mapping (ORM) frameworks and web frameworks that client applications can use with SQL Server, Azure SQL Database, Azure SQL Managed Instance, or Azure Synapse Analytics. You can use the frameworks on Linux, Windows, or Docker.
Language | Platform | ORM(s) |
---|---|---|
C# | Windows, Linux, macOS | Entity Framework Entity Framework Core |
Java | Windows, Linux, macOS | Hibernate ORM |
PHP | Windows, Linux, macOS | Laravel (Eloquent) Doctrine |
Node.js | Windows, Linux, macOS | Sequelize ORM |
Python | Windows, Linux, macOS | Django |
Ruby | Windows, Linux, macOS | Ruby on Rails |
Next steps
- For connectivity architecture information, see Azure SQL Database Connectivity Architecture.
- Find SQL Server drivers that are used to connect from client applications.
- Connect to Azure SQL Database or Azure SQL Managed Instance:
- Connect and query using .NET (C#)
- Connect and query using PHP
- Connect and query using Node.js
- Connect and query using Java
- Connect and query using Python
- Connect and query using Ruby
- Install sqlcmd and bcp the SQL Server command-line tools on Linux - For Linux users, try connecting to Azure SQL Database or Azure SQL Managed Instance using sqlcmd.
- Retry logic code examples:
- Connect resiliently with ADO.NET
- Connect resiliently with PHP
Feedback
How to Query Azure Sql Database
Source: https://docs.microsoft.com/en-us/azure/azure-sql/database/connect-query-content-reference-guide
0 Response to "How to Query Azure Sql Database"
Post a Comment