# How to copy SQL Server data to Elasticsearch using LogStash

**URL:** <https://discuss.elastic.co/t/how-to-copy-sql-server-data-to-elasticsearch-using-logstash/235064>\
**Category:** Logstash\
**Created:** [May 31, 2020, 12:25pm UTC](https://discuss.elastic.co/t/how-to-copy-sql-server-data-to-elasticsearch-using-logstash/235064 "2020-05-31T12:25:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naushad\_Ansari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/naushad_ansari1/32/69449_2.png) [@Naushad\_Ansari1](https://discuss.elastic.co/u/Naushad_Ansari1)\
**Post date:** [May 31, 2020, 12:25pm UTC](https://discuss.elastic.co/t/how-to-copy-sql-server-data-to-elasticsearch-using-logstash/235064/1 "2020-05-31T12:25:34Z")

</div>

As a developer working with SQL Server there is a need to import data from the database to Elasticsearch and analyze data in Kibana

---

<div class="post-metadata">

**Author:** ![webmat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/webmat/32/46191_2.png) [@webmat](https://discuss.elastic.co/u/webmat)\
**Post date:** [June 1, 2020, 2:47pm UTC](https://discuss.elastic.co/t/how-to-copy-sql-server-data-to-elasticsearch-using-logstash/235064/2 "2020-06-01T14:47:56Z")

</div>

Hello,

The JDBC input plugin is your best bet, to do this with Logstash. This input plugin even has built-in support to set the import schedule.

[https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html)

If this isn't flexible enough, another option is to build a small script using one of the Elasticsearch client libraries.

[https://www.elastic.co/guide/en/elasticsearch/client/index.html](https://www.elastic.co/guide/en/elasticsearch/client/index.html)

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [June 1, 2020, 3:32pm UTC](https://discuss.elastic.co/t/how-to-copy-sql-server-data-to-elasticsearch-using-logstash/235064/3 "2020-06-01T15:32:31Z")

</div>

here is example

```
input {
    jdbc {
        jdbc_validate_connection => false
        jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
        jdbc_connection_string => "jdbc:sqlserver://server_name;databaseName=db_name;user=username;password=password;"
        jdbc_user => "username"
        jdbc_password => "password"
        statement => "select * from db_name.table_view_name"
        schedule => "00 06 * * *"
        clean_run=>true
       }
}
```

---

<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:** [June 29, 2020, 3:32pm UTC](https://discuss.elastic.co/t/how-to-copy-sql-server-data-to-elasticsearch-using-logstash/235064/4 "2020-06-29T15:32:33Z")

</div>

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