# SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746

- **ID:** `php/pdo-sqlsrv-connection-failure`
- **Domain:** php
- **Category:** network_error
- **Error Code:** `08001`
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

The PHP PDO_SQLSRV connection fails due to TLS protocol mismatch between the client ODBC driver and the SQL Server, often after SQL Server disables older TLS versions (e.g., TLS 1.0/1.1) or the client lacks a required cipher suite.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| php 8.1 | active | — | — |
| php 8.2 | active | — | — |
| php 8.3 | active | — | — |
| ODBC Driver 17 for SQL Server | active | — | — |
| ODBC Driver 18 for SQL Server | active | — | — |

## Workarounds

1. **Update the ODBC driver to version 18 and configure TLS settings in the connection string: `$conn = new PDO('sqlsrv:Server=host;Database=db;Encrypt=yes;TrustServerCertificate=yes;LoginTimeout=30;', $user, $pass);`** (85% success)
   ```
   Update the ODBC driver to version 18 and configure TLS settings in the connection string: `$conn = new PDO('sqlsrv:Server=host;Database=db;Encrypt=yes;TrustServerCertificate=yes;LoginTimeout=30;', $user, $pass);`
   ```
2. **Add `'CryptoProtocolVersion' => 'TLSv1.2'` to the connection string or set the environment variable `ODBCSYSINI` to point to a custom `odbc.ini` with `CryptoProtocolVersion=TLSv1.2`.** (80% success)
   ```
   Add `'CryptoProtocolVersion' => 'TLSv1.2'` to the connection string or set the environment variable `ODBCSYSINI` to point to a custom `odbc.ini` with `CryptoProtocolVersion=TLSv1.2`.
   ```

## Dead Ends

- **Reinstalling the ODBC driver without updating TLS settings** — The default ODBC driver installation may still use outdated TLS configurations; reinstalling alone does not change the TLS protocol negotiation behavior. (70% fail)
- **Downgrading PHP to an older version (e.g., 7.4)** — The TLS handshake failure is not a PHP version issue but a driver-level configuration problem; downgrading PHP does not alter the ODBC driver's TLS behavior. (90% fail)
