# MSSQL to CSV to E-mail

**URL:** <https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353>\
**Category:** General\
**Created:** [5 November 2020 05:17 UTC](https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353 "2020-11-05T05:17:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![maa1](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@maa1](https://discourse.nodered.org/u/maa1)\
**Post date:** [5 November 2020 05:17 UTC](https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353/1 "2020-11-05T05:17:43Z")

</div>

Hi,

I'm using MSSQL node for reading data from SQL table and I want to output into either .csv or .xlsx and send it over e-mail as attachment.

I'm getting error "This node only handles CSV strings or js objects."

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [5 November 2020 07:29 UTC](https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353/2 "2020-11-05T07:29:31Z")

</div>

That's very interesting, but unless you tell us which bit you are having trouble with it is difficult to help.  
Search the node red flows site for CSV to find how to do that and search for email for how to do that.

---

<div class="post-metadata">

**Author:** ![maa1](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@maa1](https://discourse.nodered.org/u/maa1)\
**Post date:** [6 November 2020 03:59 UTC](https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353/3 "2020-11-06T03:59:25Z")

</div>

@Colin

I'm having trouble in both side i.e. from SQL to CSV and unable to attach CSV to mail.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 November 2020 09:33 UTC](https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353/4 "2020-11-06T09:33:39Z")

</div>

Show us the output (from a debug node) of your sql query and tell us what you want to see in the csv file.

What problem are you having attaching the file to an email?

---

<div class="post-metadata">

**Author:** ![Peter](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/peter/32/25135_2.png) [@Peter](https://discourse.nodered.org/u/Peter)\
**Post date:** [6 November 2020 10:30 UTC](https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353/5 "2020-11-06T10:30:08Z")

</div>

I Also would like to have a better understanding of how to achieve this proses as i need the same on one of my projects ,

Thanks and looking forward to your responses

---

<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:** [6 November 2020 11:58 UTC](https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353/6 "2020-11-06T11:58:07Z")

</div>

The data from mssql-plus SELECT is an array. Have you tried feeding through a CSV?

Note, if necessary, use a change node to move the data array into payload before the CSV node.

As for making the data an email attachment, there are several examples in the forum on this.

---

<div class="post-metadata">

**Author:** ![maa1](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@maa1](https://discourse.nodered.org/u/maa1)\
**Post date:** [7 November 2020 01:50 UTC](https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353/7 "2020-11-07T01:50:23Z")

</div>

@Steve-Mcl,

I'll check. Thanks.

---

<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:** [21 November 2020 01:50 UTC](https://discourse.nodered.org/t/mssql-to-csv-to-e-mail/35353/8 "2020-11-21T01:50:24Z")

</div>

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