Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest Fabric, Power BI, and SQL learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Get connected to a SQL pool in Azure Synapse.
Important
Use Microsoft Entra authentication when possible. For more information, see Use Microsoft Entra authentication for authentication with Synapse SQL.
The server name in the following example is sqlpoolservername.database.windows.net
. To find the fully qualified server name:
Go to the Azure portal.
Select Azure Synapse Analytics.
Select the SQL pool you want to connect to.
Locate the full server name.
SQL pool works with various drivers. Select any of the following drivers for the latest documentation and version information: ADO.NET, ODBC, PHP, and JDBC.
You can automatically generate a connection string for your driver. Select a driver from the previous list and then select Show database connection strings.
Note
Consider setting the connection timeout to 300 seconds to allow your connection to survive short periods of unavailability.
Here are examples of connection strings for popular drivers:
This simple example uses SQL authentication, but Microsoft Entra authentication with ADO.NET is more secure and recommended.
Server=tcp:{your_server}.database.windows.net,1433;Database={your_database};User ID={your_user_name};Password={your_password_here};Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
This simple example uses SQL authentication, but Microsoft Entra authentication with ODBC is more secure and recommended.
Driver={SQL Server Native Client 11.0};Server=tcp:{your_server}.database.windows.net,1433;Database={your_database};Uid={your_user_name};Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;
This simple example uses SQL authentication, but Microsoft Entra authentication with PHP is more secure and recommended.
Server: {your_server}.database.windows.net,1433 \r\nSQL Database: {your_database}\r\nUser Name: {your_user_name}\r\n\r\nPHP Data Objects(PDO) Sample Code:\r\n\r\ntry {\r\n $conn = new PDO ( \"sqlsrv:server = tcp:{your_server}.database.windows.net,1433; Database = {your_database}\", \"{your_user_name}\", \"{your_password_here}\");\r\n $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );\r\n}\r\ncatch ( PDOException $e ) {\r\n print( \"Error connecting to SQL Server.\" );\r\n die(print_r($e));\r\n}\r\n\rSQL Server Extension Sample Code:\r\n\r\n$connectionInfo = array(\"UID\" => \"{your_user_name}\", \"pwd\" => \"{your_password_here}\", \"Database\" => \"{your_database}\", \"LoginTimeout\" => 30, \"Encrypt\" => 1, \"TrustServerCertificate\" => 0);\r\n$serverName = \"tcp:{your_server}.database.windows.net,1433\";\r\n$conn = sqlsrv_connect($serverName, $connectionInfo);
This simple example uses SQL authentication, but Microsoft Entra authentication with JDBC is more secure and recommended.
jdbc:sqlserver://yourserver.database.windows.net:1433;database=yourdatabase;user={your_user_name};password={your_password_here};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
SQL pool standardizes certain settings during connection and object creation. These settings cannot be overridden. They include:
SQL pool setting | Value |
---|---|
ANSI_NULLS | ON |
QUOTED_IDENTIFIERS | ON |
DATEFORMAT | mdy |
DATEFIRST | 7 |
To connect and query with Visual Studio, see Query with Visual Studio. To learn more about authentication options, see Authentication to Azure Synapse Analytics.
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest Fabric, Power BI, and SQL learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayTraining
Module
Use Azure Synapse serverless SQL pool to query files in a data lake - Training
Use Azure Synapse serverless SQL pool to query files in a data lake
Certification
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.
Documentation
Connection strings for Synapse SQL - Azure Synapse Analytics
Connection strings for Synapse SQL
Connect to Synapse SQL - Azure Synapse Analytics
Get connected to Synapse SQL.
Connect to Synapse SQL with SQL Server Management Studio - Azure Synapse Analytics
Use SQL Server Management Studio (SSMS) to connect to and query Synapse SQL in Azure Synapse Analytics.