Convert all row table to column in Hana

You can convert all row table to column table with below procedure:

create procedure convert_column() LANGUAGE SQLSCRIPT AS
CURSOR C_TABLE
FOR SELECT 'ALTER TABLE "' || TABLE_NAME || '" COLUMN;' AS SQLTEXT
FROM SYS.TABLES
WHERE SCHEMA_NAME = 'SAPABAP1' AND TABLE_TYPE = 'ROW' and temporary_table_type = 'NONE';
BEGIN
OPEN C_TABLE;
FOR cur_row AS C_TABLE DO
EXEC cur_row.SQLTEXT;
END FOR;
END;

You can execute below procedure like this:

CALL convert_column;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.