cancel
Showing results for 
Search instead for 
Did you mean: 

Replacing multiple occurrence of space in column names to underscore

former_member597564
Participant
0 Kudos

Hello all,

How to Replace multiple occurrence of space in column names to underscore

Column names:

Effective date time

Expected : Effective_date_time

BR

Nagendra

Accepted Solutions (0)

Answers (1)

Answers (1)

KonradZaleski
Active Contributor

Simply use REPLACE function:

SELECT REPLACE('Effective date time',' ', '_') AS UNDERSCORE_COL FROM DUMMY;
former_member597564
Participant
0 Kudos

This will not work ..I am getting incorrect syntax near date

KonradZaleski
Active Contributor
0 Kudos

Syntax which I pasted is valid. So there must be another issue in your query.

KonradZaleski
Active Contributor

I read your question again and now realized that you are asking about column names. So you can simply add alias and put desired column name:

SELECT
"Effective date time" AS "Effective_date_time"