Or even, slightly shorter: EXECUTE 'SELECT ' || array_to_string(ARRAY( SELECT a.attname FROM pg_class c, pg_namespace n, pg_attribute a WHERE n.oid = c.relnamespace AND a.attrelid = c.oid AND a.attnum >= 1 AND n.nspname = 'myschema' AND c.relname = 'mytbl' AND a.attname <> 'bad_field' ORDER by a.attnum), ', ') || ' FROM myschema.mytbl'; /E