Explore this snippet here.
One method to check if the current session has access to a column is to use the COL_LENGTH
function, which returns the length of a column in bytes.
If the column doesn't exist (or cannot be accessed), COL_LENGTH returns null.
select
col_length('Orders', 'Sales') as does_exist,
col_length('Orders', 'Shmales') as does_not_exist
does_exist | does_not_exist |
---|---|
8 | NULL |