Last active
March 10, 2022 14:46
-
-
Save jerryclinesmith/cb2e84a40113ac0e49e7396f99861763 to your computer and use it in GitHub Desktop.
AWS Redshift: column names for table, column delimited
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- LISTAGG only works on user created tables, so need this hack | |
create table #cols (column_name varchar(255), ordinal_position int) | |
insert into #cols | |
select column_name, ordinal_position | |
from SVV_COLUMNS | |
where table_name = '<table name>' and table_schema = '<schema name>' | |
select LISTAGG(column_name, ', ') within group (order by ordinal_position) from #cols | |
drop table #cols |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment