# Sql\_last\_start error

**URL:** <https://discuss.elastic.co/t/sql-last-start-error/45048>\
**Category:** Logstash\
**Created:** [March 21, 2016, 9:21pm UTC](https://discuss.elastic.co/t/sql-last-start-error/45048 "2016-03-21T21:21:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkdenton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkdenton/32/28732_2.png) [@jkdenton](https://discuss.elastic.co/u/jkdenton)\
**Post date:** [March 21, 2016, 9:21pm UTC](https://discuss.elastic.co/t/sql-last-start-error/45048/1 "2016-03-21T21:21:02Z")

</div>

I get the following error when attempting to use a column value or when using the default timestamp:

Java::ComMicrosoftSqlserverJdbc::SQLServerException: Incorrect syntax near ':'.: SELECT \* from table where id \> :sql\_last\_start {:level=\>:error}  
Exception when executing JDBC query {:exception=\>#\<Sequel::DatabaseError: Java::ComMicrosoftSqlserverJdbc::SQLServerException: Incorrect syntax near ':'.\>, :level=\>:warn}

config file:

input {  
jdbc {  
type =\> "cxusermetric"  
jdbc\_driver\_library =\> "/app/logstash/sqljdbc\_4.2/sqljdbc41.jar"  
jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
jdbc\_connection\_string =\> ""  
jdbc\_user =\> ""  
jdbc\_password =\> ""  
statement =\> "SELECT \* from table where id \> :sql\_last\_start"  
use\_column\_value =\> true  
tracking\_column =\> id  
}  
}

logstash 2.2.2  
logstash-input-jdbc (3.0.0)

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 21, 2016, 9:27pm UTC](https://discuss.elastic.co/t/sql-last-start-error/45048/2 "2016-03-21T21:27:06Z")

</div>

Doesn't SQL Server use ? as the placeholder for parameters? Also, for logstash-input-jdbc 3.0.0 the parameter is named sql\_last\_value, not sql\_last\_start.

---

<div class="post-metadata">

**Author:** ![jkdenton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkdenton/32/28732_2.png) [@jkdenton](https://discuss.elastic.co/u/jkdenton)\
**Post date:** [March 21, 2016, 9:34pm UTC](https://discuss.elastic.co/t/sql-last-start-error/45048/3 "2016-03-21T21:34:51Z")

</div>

> [@magnusbaeck](#):
>
> sql\_last\_value

I tried ? but got a similar error:

Java::ComMicrosoftSqlserverJdbc::SQLServerException: Incorrect syntax near '?'.: SELECT \* from table where id \> ?sql\_last\_value {:level=\>:error}  
Exception when executing JDBC query {:exception=\>#\<Sequel::DatabaseError: Java::ComMicrosoftSqlserverJdbc::SQLServerException: Incorrect syntax near '?'.\>, :level=\>:warn}

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 22, 2016, 6:43am UTC](https://discuss.elastic.co/t/sql-last-start-error/45048/4 "2016-03-22T06:43:21Z")

</div>

I meant `SELECT * from table where id > ?`. AFAICT that's the syntax for a parameterized query in SQL Server. Maybe named parameters are supported via some other mechanism. The the SQL Server documentation.

---

<div class="post-metadata">

**Author:** ![jkdenton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkdenton/32/28732_2.png) [@jkdenton](https://discuss.elastic.co/u/jkdenton)\
**Post date:** [March 28, 2016, 2:31pm UTC](https://discuss.elastic.co/t/sql-last-start-error/45048/5 "2016-03-28T14:31:40Z")

</div>

Sorry for the delayed response, but changing the parameter to sql\_last\_value (from sql\_last\_start) fixed the problem. The placeholder for sql server was correct.

---

<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:** [July 6, 2017, 5:05am UTC](https://discuss.elastic.co/t/sql-last-start-error/45048/6 "2017-07-06T05:05:10Z")

</div>

Closed on July 6, 2017, 5:05am UTC


