# SQL Server database

## Telosys database configuration

Below are examples of typical configurations for a **SQL Server** database.

### Since Telosys 4.3

```yaml
  - id: sqlsrv
    name: SQL Server database 
    type: SQLSERVER
    # JDBC configuration
    url: jdbc:sqlserver://localhost:1433;databaseName=MyDB
    user: john_doe
    password: not_to_reveal
    # Metadata parameters
    schema: cars
```

### Before Telosys 4.3

```yaml
  - id: sqlsrv
    name: SQL Server database 
    type: SQLSERVER
    # JDBC configuration
    driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
    url: jdbc:sqlserver://localhost:1433;databaseName=MyDB
    user: john_doe
    password: not_to_reveal
    # Metadata parameters
    catalog: '!'
    schema: cars
    tableNamePattern: '%'
    tableTypes: TABLE    
```

### Other JDBC URL examples

```
jdbc:sqlserver://localhost:1433;databaseName=TestDB;encrypt=true;trustServerCertificate=true;

```

### JDBC driver

* Download:
  * Web site:  <https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server>&#x20;
  * MVN Repository: <https://mvnrepository.com/search?q=mssql-jdbc>&#x20;
* JAR file examples : &#x20;
  * mssql-jdbc-13.2.1.jre8.jar&#x20;
  * mssql-jdbc-13.2.1.jre11.jar
* Driver class name : **com.microsoft.sqlserver.jdbc.SQLServerDriver**&#x20;

## Technical information about SQL Server

### Structure

Server (instance) → **Database** → **Schema** → Tables/Objects&#x20;

<div align="left"><figure><img src="https://434201135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZMZz3NJC5MgGbWIG7J%2Fuploads%2FfeRMQkzApiwu1Q2eumjW%2Fimage.png?alt=media&#x26;token=41ecbd05-591e-4c31-8f5b-98736e80e112" alt="" width="287"><figcaption></figcaption></figure></div>

* **Database**: A physical database (similar to PostgreSQL). You must connect to a specific database. Each database is isolated, though cross-database queries are possible (`db1.dbo.table1`).
* **Schema**: A namespace *within a database*. Default schema is usually `dbo`. Users can own schemas, and schemas provide organizational and security boundaries.
