# “Machine Utilization Example” - Push data to MSSQL Database

In this file, data is pushed to an MSSQL database.

Download:

{% file src="/files/4QpFf8NvVhd28nUf7YjO" %}

{% code lineNumbers="true" %}

```yaml
description: >
    Sample MSSQL service commissioning file

metadata:
    name: MSSQL push service
    icon: https://www.cybus.io/wp-content/uploads/2017/10/for-whom1.svg
    provider: cybus
    homepage: https://www.cybus.io
    version: 1.0.0

parameters:
    mssqlHost:
        type: string
        default: 172.17.0.1

    mssqlPort:
        type: integer
        default: 1433

    mssqlUser:
        type: string
        default: sa

    mssqlPassword:
        type: string
        default: SomeLongSecurePassw0rd

    mssqlDatabase:
        type: string
        default: tempdb

resources:
    mssqlDB:
        type: Cybus::Container
        properties:
            image: mcr.microsoft.com/mssql/server
            ports:
                - 1433:1433/tcp
            environment:
                SA_PASSWORD: 'SomeLongSecurePassw0rd'
                ACCEPT_EULA: 'Y'

    mssqlConnection:
        type: Cybus::Connection
        properties:
            protocol: Mssql
            connection:
                host: !ref mssqlHost
                port: !ref mssqlPort
                username: !ref mssqlUser
                password: !ref mssqlPassword
                database: !ref mssqlDatabase

    mssqlQuery2:
        type: Cybus::Endpoint
        properties:
            protocol: Mssql
            connection: !ref mssqlConnection
            write:
                # Here we use the placeholder @someValue. The protocol driver will insert
                # the value from the input JSON message under the key someValue
                query: 'INSERT INTO machine (powerlevel, state, timestamp) VALUES (@powerlevel, @state, @timestamp)'

    mapping:
        type: Cybus::Mapping
        properties:
            mappings:
                - subscribe:
                      topic: 'machine-state'
                  publish:
                      endpoint: !ref mssqlQuery2
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cybus.io/1-7-3/documentation/services/sample-service-commissioning-files/machine-utilization-example-multi-file-service-composition-modbus-tcp-+-influxdb-+-grafana-+-mss/machine-utilization-example-push-data-to-mssql-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
