Home > Forum > General > Running the SQL procedure so that the generated result can be downloaded as a .txt file

Running the SQL procedure so that the generated result can be downloaded as a .txt file
0

I would like to run an SQL procedure (something like the article Run an SQL procedure https://community.webcon.com/posts/post/the-run-an-sql-procedure-action/230).
But, I would like the procedure to generate a .txt file with the results (e.g. JSON), and the file to be downloaded using the WEBCON platform (maybe a new process with starting the procedure and preparing a .txt file for download, such as an attachment).
Is it possible, if so how?

MVP

Hi Radek,

I have two ideas, I have tested none of them but each single step would work so they should work also in the combination. :)

1. Create binary attachment
1.a) Transform the result to a text
1.b) Convert the varchar result to varbinary
https://dba.stackexchange.com/questions/63743/converting-a-varchar-to-varbinary
1.c) Use the binary to add as an attachment
https://community.webcon.com/forum/thread/2375

2. PowerShell action and hotfolder
2.a) Execute a PowerShell action to call the sql procedure
2.b) Store the result in a folder with something like InstanceId_Result.txt
2.c) Add a hotfolder to check for new files
2.d) Create a process for each new file
2.e) Get the instance id from the file name and trigger a "move workflow"
2.f) Fetch the file from the temporary process created by the hotfolder
2g) delete the temporary process


Best regards,
Daniel