SQL Server:选择前 0?

问题描述:

我们刚刚在旧的生产存储过程中遇到了这个问题(这里还有很多事情要做,但这只是其逻辑的一个方面).为什么有人会从表中选择前 0 行?这是我不熟悉的某种 SQL hack 或技巧吗?

We just came across this in an old production stored proc (there is a lot more going on in here, but this is in one leg of its logic). Why would someone ever select top 0 rows from a table? Is this some sort of SQL hack or trick I am not familiar with?

在 UNION ALL 中命名列

To name columns in a UNION ALL

请务必阅读 Alex K. 的回答.他有很多我也用过的理由.这只是最明显的一个.

Be sure to read Alex K.'s answer as well. He has a lot of reasons that I have used as well. This was just the most obvious one.