cancel
Showing results for 
Search instead for 
Did you mean: 

concatenate all columns that can be used for several tables regardless of the number of columns

pepeverdu
Explorer
0 Kudos

Hello everyone,

I am trying to concatenate all the columns from a table into a new table with one column. The problem I have is when I am trying to use the code for different columns dimensions and dont know the name of the columns.

Can someone help me??

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

pepeverdu
Explorer

here is what i found.

CREATE OR REPLACE PROCEDURE EXT.SP_GET LANGUAGE SQLSCRIPT SQL SECURITY INVOKER DEFAULT SCHEMA "EXT" AS
BEGIN
	exec 'INSERT INTO "EXT"."table_PRUEBA" SELECT ' || (SELECT STRING_AGG(COLUMN_NAME,'|| '','' ||' order by POSITION) 
	FROM "SYS"."TABLE_COLUMNS" 
	WHERE TABLE_NAME = 'table1'
	)
	|| ' FROM table1';

END;

Answers (0)