# Index data to elasticsearch from SQL Server

**URL:** <https://discuss.elastic.co/t/index-data-to-elasticsearch-from-sql-server/163553>\
**Category:** Elasticsearch\
**Created:** [January 9, 2019, 2:41pm UTC](https://discuss.elastic.co/t/index-data-to-elasticsearch-from-sql-server/163553 "2019-01-09T14:41:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsron143](https://avatars.discourse-cdn.com/v4/letter/i/a6a055/32.png) [@itsron143](https://discuss.elastic.co/u/itsron143)\
**Post date:** [January 9, 2019, 2:41pm UTC](https://discuss.elastic.co/t/index-data-to-elasticsearch-from-sql-server/163553/1 "2019-01-09T14:41:40Z")

</div>

I have a database in my SQL Server which has multiple tables and the size of the database is around 25 GB.  
I want to index this data to Elasticsearch 5.6 (As it supports mapping of multiple types). However the column names in some of the tables have invalid name such as a [.] in between words, etc.  
I'd like to convert all the tables into a single json file and then fix the field names and then index the data to elasticsearch. I'm having a hard time figuring out how to do this. I've read some links such as [this](https://codeshare.co.uk/blog/how-to-copy-sql-server-data-to-elasticsearch-using-logstash/) and [this](https://www.pluralsight.com/blog/it-ops/elasticsearch-and-sql-server) but I need to fix the column names before indexing.

How do I convert the SQL tables (multiple) into json and then after fixing the names, index it to elasticsearch? Are there any other ways to fix this?

---

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [January 9, 2019, 3:01pm UTC](https://discuss.elastic.co/t/index-data-to-elasticsearch-from-sql-server/163553/2 "2019-01-09T15:01:20Z")

</div>

Hello,

we can load data by writing the query, and the names which are not proper can be replaced by giving alias names,  
Ex  
select id\_value as id, name.keyword as name from sample

---

<div class="post-metadata">

**Author:** ![itsron143](https://avatars.discourse-cdn.com/v4/letter/i/a6a055/32.png) [@itsron143](https://discuss.elastic.co/u/itsron143)\
**Post date:** [January 9, 2019, 3:03pm UTC](https://discuss.elastic.co/t/index-data-to-elasticsearch-from-sql-server/163553/3 "2019-01-09T15:03:30Z")

</div>

there are hundreds of such columns. I was thinking of doing a search and replace after converting the tables into JSON as that feels easier

---

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [January 9, 2019, 3:06pm UTC](https://discuss.elastic.co/t/index-data-to-elasticsearch-from-sql-server/163553/4 "2019-01-09T15:06:25Z")

</div>

yup, as per my knowledge,

create a new table with proper data and columns and load the data or else using alias names

---

<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:** [February 6, 2019, 3:06pm UTC](https://discuss.elastic.co/t/index-data-to-elasticsearch-from-sql-server/163553/5 "2019-02-06T15:06:26Z")

</div>

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