Coffee77
Honored Contributor III

I think there is no automatic way of achieving this BUT try (and customize if needed) this script 😎. Change "source_schema" and "table_schema" as per your needs, and then run it as a query in a SQL Warehouse cluster:

WITH table_tags AS (
    SELECT
        catalog_name,
        schema_name,
        table_name,
        NULL AS column_name,
        tag_name,
        tag_value
    FROM INFORMATION_SCHEMA.TABLE_TAGS
    WHERE schema_name = 'source_schema'

),
column_tags AS (
    SELECT
        catalog_name,
        schema_name,
        table_name,
        column_name,
        tag_name,
        tag_value    
    FROM INFORMATION_SCHEMA.COLUMN_TAGS
    WHERE schema_name = 'source_schema'
)
SELECT 
    'ALTER TABLE target_schema.' || table_name ||
    ' SET TAGS ("' || tag_name || '"="' || tag_value || '");' AS generated_sql
FROM table_tags
UNION ALL
SELECT            
    'ALTER TABLE target_schema.' || table_name ||
    ' ALTER COLUMN ' || column_name ||
    ' SET TAGS ("' || tag_name || '"="' || tag_value || '");' AS generated_sql
FROM column_tags

 


Lifelong Solution Architect Learner | Coffee & Data

View solution in original post