You are viewing limited content. For full access, please sign in.

Question

Question

export csv from SQL

asked on April 11, 2022

Good afternoon,

 

We are trying to export a CSV file from a SQL table using workflow scripts, but I'm not very familiar with C#.  Can anyone share a C# code to export the table? we will need a sample using the On-Prem and also on Cloud because I believe the cloud code is different (we already configure the worked on the cloud).

 

I appreciate your help on this,

Thanks,

Pedro

0 0

Replies

replied on April 11, 2022

Hi Pedro-

I don't have a working sample, but if I remember correctly the gist would be to loop through your data, adding rows--token values separated by commas--to a multi-valued token. Then use a separate token to hold all those rows combined and separated by a line break.

From there, C# script to write to file. Don't forget to include a using reference for System.IO

            string csvText = GetTokenValue("All Rows Combined").ToString();
            string reportPath = GetTokenValue("Report Path").ToString();
            string reportName = GetTokenValue("Report Filename").ToString();
            string fullPath = Path.Combine(reportPath, reportName);
            File.WriteAllText(fullPath,csvText);

 

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.