Create CSV file from MSSQL-Plus stored procedure?

Is there a way to create a csv file from an array that is being returned by a MSSQL stored procedure? I would like for this .csv file to be created & placed on a network share or other convenient location.

Yes. But without data examples it is hard to say how.

Here is what the CSV looks like that is generated by the stored procedure.

I use the CSV and File nodes to export out the data returned from a SQL query in mySQL and then FTP node to put it on a NAS (not stored procedure from MSSQL), but I think it should be the similar. The relevant section of the flow is below - hope this helps.

[{"id":"62e86954.30b21","type":"switch","z":"934f1005.6e02","g":"e9e479b2.d1c26","name":"Record count > 0","property":"$count(payload)","propertyType":"jsonata","rules":[{"t":"gt","v":"0","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":270.66668701171875,"y":2681,"wires":[["e044e5aa.ccf9"],["7b739ef5.766258"]]},{"id":"e044e5aa.ccf9","type":"csv","z":"934f1005.6e02","g":"e9e479b2.d1c26","name":"","sep":",","hdrin":"","hdrout":"all","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":true,"include_null_values":true,"x":481.66668701171875,"y":2676,"wires":[["a1a3d10a.321a7"]]},{"id":"a1a3d10a.321a7","type":"file","z":"934f1005.6e02","g":"e9e479b2.d1c26","name":"Save Logs CSV","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"true","encoding":"none","x":642.9999694824219,"y":2675.66650390625,"wires":[["2025b474.5c5fb4"]]},{"id":"2025b474.5c5fb4","type":"change","z":"934f1005.6e02","g":"e9e479b2.d1c26","name":"Set FTP File Paths","rules":[{"t":"set","p":"localFilename","pt":"msg","to":"filename","tot":"msg"},{"t":"set","p":"filename","pt":"msg","to":"ftpFilename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860.9998474121094,"y":2675.666748046875,"wires":[["55eda512.15332c"]]}]

It would be best to supply data in a copyable format.
You need to supply a copy of the incoming data from the sql query and a copy of how the csv should look.
Images are not any help when supplying data.

Thank you for the pointers. The CSV node should do the trick, but for some reason I am getting only 4 rows of my expected output.

When I put the Debug node at the end of the MSSQL-PLUS node, I can see the expected output:

But when I put the Debug node at the end of the CSV node, I am getting only the first 4 rows of data (the blue colored rows). The Excel file is as I get the data from SQL.

Here is how I configured the CSV node. I have tried several different settings and still get the same general results. Is there any possible reason why the CSV would only capture the first 4 rows?

If you are looking at the output in the debug node, I believe that node displays only a limited number of characters. See this topic:

If you use the file node to output the data, I think you will see the entire dataset.

My CSV Node Configuration:

My file node configuration:

Thank you! The CSV node + File node is all that was needed. The rest is just me working out the nitty-gritty details of the CSV and then saving the file somewhere where I can access it. Really appreciate this.

1 Like

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