Skip to content

Instantly share code, notes, and snippets.

@jerryclinesmith
Last active March 10, 2022 14:46
Show Gist options
  • Save jerryclinesmith/cb2e84a40113ac0e49e7396f99861763 to your computer and use it in GitHub Desktop.
Save jerryclinesmith/cb2e84a40113ac0e49e7396f99861763 to your computer and use it in GitHub Desktop.
AWS Redshift: column names for table, column delimited
-- 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