Excluding Columns From Select All In Snowflake

Alvaro Parra
2 min readAug 1, 2023

--

In Snowflake, the SELECT * statement is a quick way to retrieve all columns from a table. However, there may be times when you want to exclude certain columns from the Select. In this article we will discuss the options that we have for doing it.

For doing it you will have to use the exclude function.

Step 1. Using The Exclude Function

Exclude function helps us to bannish columns from a select * statement.

For example we were making comparisons in two datasets on an article on How To Compare Two Tables In Snowflake.

The first dataset had the following information

The second dataset had this information

For example if we wanted to make a comparison of both datasets without ‘EMAIL’ column without using the exclude function we would need to run the following query

Then if we are using exclude function this would be much easier as you will only need to call the following sql query.

Both queries are going to return the same result.

Conclusion

This function was built in order to help you to save time by avoiding writing all column names when there is no need of doing it, Imagine if you had a table with 100 columns, you will need to mention all the columns and the query would be longer due column names.

--

--

Alvaro Parra

Data Engineer | Freelancer, dedicated to work in Snowflake and Azure.