Where We’re Going, We Don’t Need Limits

There is always a lot of fun things you can learn to do with Snowflake. Sometimes they’re even in the places you least expect to find anything even slightly different.

Take for example LIMIT.

SELECT * FROM public.employees LIMIT 20;

Most of us have written the statement above – or something like it – a thousand times. But, in Snowflake, you can also write this:

SELECT * FROM employees LIMIT;

Yes, that’s right. There is no number or anything after the keyword LIMIT. What the heck?

This actually returns everything in the table. In SQL Server, you could do something I’ve seen a few times:

SELECT TOP 100000000000000 * FROM dbo.employees;

Yes, you do have the possibility of having more rows than the amount of you have specified in the query – let’s just hope that the place that has that many employees has really really good benefits and great managers.

But, what happens in Snowflake, if you do the following:

SELECT * FROM public.employees LIMIT '';

You would think it would be a syntax error. And you would be wrong…

It actually returns all rows from the table.

I get the same thing with LIMIT NULL or LIMIT $$$$.

Will you find this useful in your future endeavors in querying Snowflake tables? Maybe… Maybe not… Only the Shadow knows…

Until next time my friends…

Leave a comment

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