# Export excel from MS SQL Server 2019

**URL:** https://discourse.nodered.org/t/export-excel-from-ms-sql-server-2019/48949
**Category:** General
**Created:** [27 July 2021 06:08 UTC](https://discourse.nodered.org/t/export-excel-from-ms-sql-server-2019/48949 "2021-07-27T06:08:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![chihiep11](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@chihiep11](https://discourse.nodered.org/u/chihiep11)
#### Post date: [27 July 2021 06:08 UTC](https://discourse.nodered.org/t/export-excel-from-ms-sql-server-2019/48949/1 "2021-07-27T06:08:51Z")

</div>

The title says it all.  
Command:

> EXEC sp\_configure 'show advanced options', 1  
> RECONFIGURE  
> GO  
> EXEC sp\_configure 'ad hoc distributed queries', 1  
> RECONFIGURE  
> GO  
> INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\Users\ThienPham\Documents\export\export.xlsx;', 'SELECT \* FROM [Sheet1$]')  
> SELECT \* FROM [DATA].[dbo].[ddt]

i excuted it on MS SQL Server 2019 software. it's good. But when i excute it on Node-red, it's not work.  
message: "Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"."  
This is my flow  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/9/c9abd9148f28eeeac7a6b21be6c4f8278ab76fc4.png)  
function code:

```auto
ena ="INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\Users\ThienPham\Documents\export\export.xlsx;', 'SELECT * FROM [Sheet1$]') ";
ena = ena + "SELECT * FROM [DATA].[dbo].[ddt]";
msg.topic = ena;
return msg;

```

infor  
OS: Window 10 pro x64  
MS SQL 2019  
SQL authentication  
Node-RED version: v1.2.9  
Node.js version: v15.13.0  
Help me! . Thanks

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [27 July 2021 06:59 UTC](https://discourse.nodered.org/t/export-excel-from-ms-sql-server-2019/48949/2 "2021-07-27T06:59:13Z")

</div>

What SQL user is setup on the MSSQL config node? Does it have the correct permissions.

Apart from that, i am unsure if the node-js SQL Server driver supports what you are attempting.

An alternative solution is to simply select the data and pass it to a CSV node then file out node (or use one of the contrib nodes that write to excel)

---

<div class="post-metadata">

### Author: ![chihiep11](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@chihiep11](https://discourse.nodered.org/u/chihiep11)
#### Post date: [28 July 2021 00:53 UTC](https://discourse.nodered.org/t/export-excel-from-ms-sql-server-2019/48949/3 "2021-07-28T00:53:59Z")

</div>

Thank you for your help. i found my issue. The problem is my function

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [11 August 2021 00:54 UTC](https://discourse.nodered.org/t/export-excel-from-ms-sql-server-2019/48949/4 "2021-08-11T00:54:47Z")

</div>

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