---
title: "Connecting to MSSQL"
canonical_url: "https://www.zone.eu/support/kb/connecting-to-mssql/"
post_type: "ht_kb"
published: "2024-04-17T08:22:47+00:00"
modified: "2024-10-04T12:28:17+00:00"
language: "en"
author: "Hasso"
taxonomies:
  ht_kb_category:
    - name: "PHP"
      url: "https://www.zone.eu/support/kb-categories/php-en/"
  ht_kb_tag:
    - name: "connection"
      url: "https://www.zone.eu/support/kb-tags/connection/"
    - name: "database"
      url: "https://www.zone.eu/support/kb-tags/database-ru/"
    - name: "db"
      url: "https://www.zone.eu/support/kb-tags/db/"
    - name: "MS"
      url: "https://www.zone.eu/support/kb-tags/ms/"
    - name: "ms sql"
      url: "https://www.zone.eu/support/kb-tags/ms-sql/"
    - name: "mssql"
      url: "https://www.zone.eu/support/kb-tags/mssql-ru/"
    - name: "php"
      url: "https://www.zone.eu/support/kb-tags/php-eng/"
    - name: "sql"
      url: "https://www.zone.eu/support/kb-tags/sql-eng/"
---

# Connecting to MSSQL

In order to connect to MSSQL, you need to activate the **PDO / DBLib** extension under PHP extensions.
To activate PHP extensions, select `Webserver` -&gt; `Main domain setting`s and from there select `modify` -&gt; `PHP extensions`.

[![](https://www.zone.eu/static/sites/5/main-domain-settings-modify-1.png)](https://www.zone.eu/support/?attachment_id=16409)

[![](https://www.zone.eu/static/sites/5/mssql1.png)](https://www.zone.eu/support/?attachment_id=16411)

Via the extensions menu, enable **`PDO / DBLib`**.

[![](https://www.zone.eu/static/sites/5/MSSQL_php_extensions.png)](https://www.zone.eu/support/?attachment_id=16412)
In order to change the settings for connecting to the MS SQL server, you need to create a new file in the home directory */data0X/virtXXX/* named **.freetds.conf**,

(NB! the file name starts with a dot) with the following contents for example:

```
[ODBC]
host = 123.123.123.123
port = 1234
tds version = 8.0
client charset = UTF-8
mssql.charset = "UTF-8"
```

Sample script for creating an MSSQL connection:

```
$pdo = new PDO('dblib:host=ODBC;dbname=database_name;', 'user', 'pass');
```

Details on how to configure .freetds.conf can be found on the [FreeTDS website.](http://www.freetds.org/userguide/freetdsconf.html)
