# OUTPUT SQL PLugin

**URL:** <https://community.influxdata.com/t/output-sql-plugin/39698>\
**Category:** Telegraf\
**Created:** [December 6, 2024, 10:33am UTC](https://community.influxdata.com/t/output-sql-plugin/39698 "2024-12-06T10:33:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rosario\_Iameo](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/rosario_iameo/32/16190_2.png) [@Rosario\_Iameo](https://community.influxdata.com/u/Rosario_Iameo)\
**Post date:** [December 6, 2024, 10:33am UTC](https://community.influxdata.com/t/output-sql-plugin/39698/1 "2024-12-06T10:33:24Z")

</div>

dear All,  
i have a telegraf agent woth modbus plugin and i qould like to write the data to mssql server.  
I tried to configure the output sql plugin but it fails to write data. i do not understand how configure it to check if table exist or create it and how to map the read value to column.

thi is telegraf file configuration

```auto
[[outputs.sql]]

driver="mssql"
timestamp_column = "timestamp"
data_source_name = "sqlserver://sa:xx@xxx.yyy.zzz.kkkk:1433/?database=test&connection+timeout=30

[[inputs.modbus]]
        name = "PM5300_SAS"
        slave_id = 255
        timeout = "2s"
        controller = "tcp://10.0.2.103:502"

        configuration_type = "register"

        holding_registers=[
                { name = "VAB", byte_order = "ABCD",data_type = "FLOAT32-IEEE",scale=1.0, a>
                { name = "VAC", byte_order = "ABCD",data_type = "FLOAT32-IEEE",scale=1.0, a>
                { name = "VBC", byte_order = "ABCD",data_type = "FLOAT32-IEEE",scale=1.0, a>
                ]

```

telegraf as created a table but cant write the value on it , the error is

```auto
[agent] Error writing to outputs.sql: mssql: Incorrect syntax near ','.

```

is there somebody can help me?

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [December 6, 2024, 8:56pm UTC](https://community.influxdata.com/t/output-sql-plugin/39698/2 "2024-12-06T20:56:17Z")

</div>

Hello @Rosario_Iameo,  
Can you please enable logs with:

```auto
[agent]
  debug = true

```

Can you try automatically creating the table first two and verifying that your columns match?

---

<div class="post-metadata">

**Author:** ![Rosario\_Iameo](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/rosario_iameo/32/16190_2.png) [@Rosario\_Iameo](https://community.influxdata.com/u/Rosario_Iameo)\
**Post date:** [December 7, 2024, 5:08pm UTC](https://community.influxdata.com/t/output-sql-plugin/39698/3 "2024-12-07T17:08:14Z")

</div>

Hello @Anaisdg ,  
telegraf create this table

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/c/3/c326b135c49cb991b46512be1829c7691258d28e.png)

and after a creation the error is

```auto
 [agent] Error writing to outputs.sql: execution failed: mssql: Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the time stamp column.

```

---

<div class="post-metadata">

**Author:** ![srebhan](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/srebhan/32/8572_2.png) [@srebhan](https://community.influxdata.com/u/srebhan)\
**Post date:** [December 11, 2024, 1:41pm UTC](https://community.influxdata.com/t/output-sql-plugin/39698/4 "2024-12-11T13:41:49Z")

</div>

@Rosario_Iameo how about adding the closing quote to `data_source_name`? 😉

---

<div class="post-metadata">

**Author:** ![Rosario\_Iameo](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/rosario_iameo/32/16190_2.png) [@Rosario\_Iameo](https://community.influxdata.com/u/Rosario_Iameo)\
**Post date:** [December 12, 2024, 8:17am UTC](https://community.influxdata.com/t/output-sql-plugin/39698/5 "2024-12-12T08:17:07Z")

</div>

this is an copy error but in the origial file the data\_source\_name is correct and with opening e closing quote 🙂
