# SQL Server

**URL:** https://forum.kx.com/t/sql-server/11694
**Category:** Community Support
**Tags:** kdb-and-q
**Created:** [January 29, 2018, 8:49pm UTC](https://forum.kx.com/t/sql-server/11694 "2018-01-29T20:49:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![TMA](https://avatars.discourse-cdn.com/v4/letter/t/ed655f/32.png) [@TMA](https://forum.kx.com/u/TMA)
#### Post date: [January 29, 2018, 8:49pm UTC](https://forum.kx.com/t/sql-server/11694/1 "2018-01-29T20:49:00Z")

</div>

Saw the ODBC connector to link KDB to SQL Server, but what would be the code to select from a table in KDB and insert it in to SQL Server, and select data from a SQL Server database and insert it in to a KDB table, could not find any examples. Regards.

---

<div class="post-metadata">

### Author: ![newstudent20171](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@newstudent20171](https://forum.kx.com/u/newstudent20171)
#### Post date: [January 30, 2018, 6:02am UTC](https://forum.kx.com/t/sql-server/11694/2 "2018-01-30T06:02:00Z")

</div>

http://code.kx.com/q/cookbook/odbc/

>

---

<div class="post-metadata">

### Author: ![Flying1](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@Flying1](https://forum.kx.com/u/Flying1)
#### Post date: [January 30, 2018, 8:31am UTC](https://forum.kx.com/t/sql-server/11694/3 "2018-01-30T08:31:00Z")

</div>

Given that the connector is basically an ODBC connection. In order to query from or insert data into SQL Server, all you need to do is to construct a proper SQL statement that you can execute in SQL Server.

---

<div class="post-metadata">

### Author: ![newstudent20171](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@newstudent20171](https://forum.kx.com/u/newstudent20171)
#### Post date: [January 30, 2018, 9:06am UTC](https://forum.kx.com/t/sql-server/11694/4 "2018-01-30T09:06:00Z")

</div>

I second flyings statement.

>

---

<div class="post-metadata">

### Author: ![TMA](https://avatars.discourse-cdn.com/v4/letter/t/ed655f/32.png) [@TMA](https://forum.kx.com/u/TMA)
#### Post date: [February 4, 2018, 8:28pm UTC](https://forum.kx.com/t/sql-server/11694/5 "2018-02-04T20:28:00Z")

</div>

Export the data on a cron and use bcp, useless tool, to batch load in to SQL Server, saves all the hassle of ODBC connections, has been running a few days and 100% stable. Thanks for the advice.
