Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to create .sql as and output file

Lumjing
8 - Asteroid

I have a excel table as below. I want to output the table below with "SQL Query" column as .sql. can you please help how to achieve this

 

Input

CodeSQL Query
123SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;

 

I am doing a output file as "123.sql"

when I open the "123.sql" file I am getting the column heading and the codes are inside a " " like below. How can I get "123.sql" file without the "SQL Query" and without the Quotes " "

 

SQL Query
"SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;"
11 REPLIES 11
PhilipMannering
16 - Nebula
16 - Nebula

@Lumjing Try mirroring this configuration in the Output Data Tool...
Screenshot 2024-03-01 095824.png

Lumjing
8 - Asteroid

@PhilipMannering  is there a way to align the query in the output it is coming as one line when I open the .sql file.

 

 Thank you for the quick help. 

jdminton
12 - Quasar

@Lumjing 

switch the delimiter to \N in the input config

PhilipMannering
16 - Nebula
16 - Nebula

@Lumjing And if that doesn't work, use Split-to-Columns tool to split your text field into rows on a "\n". Example attached.

Lumjing
8 - Asteroid

@PhilipMannering thank you for the option. The "SQL Query" in my case is in line and when I use the \n it does not split them in rows. can you please suggest any alternatives

Lumjing
8 - Asteroid

@jdminton I switch the delimiter to \n and  the output is "SELECT Orders.OrderID, Customers.CustomerName FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;"

jdminton
12 - Quasar

@Lumjing I think what you are asking is for a way to format the code so that it is more readable. There's no default for this as each coder has his or her own preferences. You can try what I've included in the No New Line container in the workflow. I've added my first explanation as well to what Philip provided. There would be lots of parsing to get this how you want based on the SQL commands used within the code. You might consider using a different tool to help with this. I use Flyspeed SQL Query tool to help with formatting or developing complex SQL queries. I believe the free version will perform the formatting you are looking for. Please confirm if that is your question. Thanks..

Lumjing
8 - Asteroid

@jdminton Thank you for the detailed description. I will check and update. Can you please share me the .txt files 

jdminton
12 - Quasar

Sorry, here is the packaged workflow with the text files.

Labels