# Sending data to SQL server

**URL:** <https://community.influxdata.com/t/sending-data-to-sql-server/21364>\
**Category:** Fluxlang\
**Tags:** influxdb, flux\
**Created:** [August 24, 2021, 1:37pm UTC](https://community.influxdata.com/t/sending-data-to-sql-server/21364 "2021-08-24T13:37:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea1](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@Andrea1](https://community.influxdata.com/u/Andrea1)\
**Post date:** [August 24, 2021, 1:37pm UTC](https://community.influxdata.com/t/sending-data-to-sql-server/21364/1 "2021-08-24T13:37:39Z")

</div>

Hi,  
i am new with Flux language and InfluxDB in general.  
What I’m trying to do is periodically transfer data from InfluxDB to SQLServer.  
I created a new Task with the following code:

```auto
import "sql"

option task = {name: "TaskTest", every: 24h}

from(bucket: "BucketTest")
	|> range(start: 0, stop: now())
	|> limit(n: 100)
	|> sql.to(driverName: "sqlserver", dataSourceName: "server=myServer;user id=myuser;password=mypsw;database=myDB;", table: "dbo.myTable")

```

This task works almost as i want: periodically it send the oldest 100 records to my SQL Server. The main problem is that I don’t know how to insert a column filter: In SQLServer I need only \_time, \_value and other custom columns, but \_start, \_end, \_field, \_measurements are useless for my scope. Is there a way to exclude these columns from sql.to() function?

---

<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:** [August 24, 2021, 7:17pm UTC](https://community.influxdata.com/t/sending-data-to-sql-server/21364/2 "2021-08-24T19:17:06Z")

</div>

Hello, @Andrea1,  
I recommend using the drop() or keep() Flux functions before using the sql.to() function.

---

<div class="post-metadata">

**Author:** ![Andrea1](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@Andrea1](https://community.influxdata.com/u/Andrea1)\
**Post date:** [August 25, 2021, 7:46am UTC](https://community.influxdata.com/t/sending-data-to-sql-server/21364/3 "2021-08-25T07:46:12Z")

</div>

Ok, keep function solved my problem. Thank you 😅

---

<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:** [August 25, 2021, 5:43pm UTC](https://community.influxdata.com/t/sending-data-to-sql-server/21364/4 "2021-08-25T17:43:12Z")

</div>

@Andrea1 of course! Thank you for marking the solution
