Alteryx Designer Desktop Discussions

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

SQL query & Alteryx workflow to remove the prefix from column names

RE5260
8 - Asteroid

Hi All,

 

Let's say I have an excel file with 10 columns, All the column header names starts with "SA_"

Like- SA_Name, SA_Sales, SA_Date etc.

 

Need to remove the prefix for all columns, which tool should I use? How to do it? 

And, what will be the SQL query to do this?

 

Kindly assist.

 

 

 

4 REPLIES 4
Raj
14 - Magnetar

Use Dynamic rename tool
PFA

BRRLL99
11 - Bolide

Use Dynamic rename tool and try this formula

Replace([_CurrentField_],"SA_","")

 

BRRLL99_0-1687170984912.png

 

BRRLL99
11 - Bolide

Try this SQL query

SELECT
CASE
WHEN SUBSTRING(column_name, 1, 3) = 'SA_' THEN SUBSTRING(column_name, 4)
ELSE column_name
END AS new_column_name
FROM
YourTableName;

 

danilang
19 - Altair
19 - Altair

Hi @BRRLL99 

 

Your query is attempting to modify the column names and won't work unless you actually have a field called "column_name" in your database.

 

To return the values in a SQL table with new column names try this

 

Select SA_Name "Name",

           SA_Sales Sales,

           SA_Date "Date"

           etc

  From tablename

 

Name and Date are both reserved words in SQL so it's a good idea to enclose them in quotes.

 

Dan

 

 

Labels