# Sql\_last\_value resets to 0 upon restart

**URL:** <https://discuss.elastic.co/t/sql-last-value-resets-to-0-upon-restart/228017>\
**Category:** Logstash\
**Created:** [April 15, 2020, 2:37am UTC](https://discuss.elastic.co/t/sql-last-value-resets-to-0-upon-restart/228017 "2020-04-15T02:37:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![priyankpatel22](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priyankpatel22/32/66328_2.png) [@priyankpatel22](https://discuss.elastic.co/u/priyankpatel22)\
**Post date:** [April 15, 2020, 2:37am UTC](https://discuss.elastic.co/t/sql-last-value-resets-to-0-upon-restart/228017/1 "2020-04-15T02:37:34Z")

</div>

It seems the variable **sql\_last\_value** gets reset every time I restart logstash. As per the documentation and all other threads it should look at **last\_run\_metadata\_path** for the last saved value. I see the last\_run\_metadata\_path is getting updated but sql\_last\_value getting reset to 0 on restart.

Here is my input -

```auto
jdbc {
    jdbc_driver_library => "C:\sqljdbc_6.4\enu\mssql-jdbc-6.4.0.jre8.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://host:1433;databaseName=db"
    jdbc_user => "user"
    jdbc_password => "pwd"
    schedule => "* * * * * *"
    statement => "SELECT * FROM dbo.IPR_LOG WHERE s_no > :sql_last_value"
    use_column_value => true
    tracking_column_type => "numeric"
    tracking_column => "s_no"
    last_run_metadata_path => "C:\Users\xyz\.custom_log"
    type => "log"
  }

```

For the note,  
**s\_no** is a "numeric" sql type value in the table.  
I am also assuming that `clean_run => false` by default.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 13, 2020, 2:37am UTC](https://discuss.elastic.co/t/sql-last-value-resets-to-0-upon-restart/228017/2 "2020-05-13T02:37:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
