Migrate to Innovate Summit:
Learn how migrating and modernizing to Azure can boost your business's performance, resilience, and security, enabling you to fully embrace AI.Register now
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This article demonstrates how to use PHP to connect to a database in Azure SQL Database or Azure SQL Managed Instance. You can then use T-SQL statements to query data.
Restore or import Adventure Works from a BACPAC file from GitHub
Restore or import Adventure Works from a BACPAC file from GitHub
Important
The scripts in this article are written to use the AdventureWorks2022 database. With a SQL Managed Instance, you must either import the AdventureWorks2022 database into an instance database or modify the scripts in this article to use the Wide World Importers database.
PHP-related software installed for your operating system:
macOS, install PHP, the ODBC driver, then install the PHP Driver for SQL Server. See Step 1, 2, and 3.
Linux, install PHP, the ODBC driver, then install the PHP Driver for SQL Server. See Step 1, 2, and 3.
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.
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 a 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 in an Azure VM. To copy the server name or host name, hover over it and select the Copy icon.
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.