Since most of the operators that are used when executing the query are defined in terms of one or more input sets of strings and one or more output sets of strings, it makes sense that if you write a query that requires the use of one of these operators, you must make sure that the input which you represent to this operator is a collection of strings.
Thus, the constant check operator is a special operator that can take one or more scalar inputs and generate a set of strings.
This simplifies the compilation of statements.
Why select top 1 getdate() gives a different result than regular select getdate()
Because you asked to use the TOP operator. And the TOP statement expects a set of input lines.
Why I think focusing on performance doesn't matter:
SET STATISTICS TIME ON GO SELECT TOP 1 GETDATE() GO SELECT GETDATE()
Messages:
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.
(1 row (s) affected)
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.
(1 row (s) affected)
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
That is, we cannot even get a measure of the time that any operator should perform.
source share