Why use Select Top 100 Percent?

后端 未结 10 2285
花落未央
花落未央 2020-11-27 15:41

I understand that prior to SQL Server 2005, you could \"trick\" SQL Server to allow use of an order by in a view definition, by also include TOP 100 PERCENT

10条回答
  •  情深已故
    2020-11-27 16:12

    No reason but indifference, I'd guess.

    Such query strings are usually generated by a graphical query tool. The user joins a few tables, adds a filter, a sort order, and tests the results. Since the user may want to save the query as a view, the tool adds a TOP 100 PERCENT. In this case, though, the user copies the SQL into his code, parameterized the WHERE clause, and hides everything in a data access layer. Out of mind, out of sight.

提交回复
热议问题