In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to sort the temporary tables in SQL Server, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
In SQL Server 2005 ORDER BY 2008, if ordered records are inserted into a temporary table, the records queried from the temporary table are ordered (not dependent on ORDER BY), but starting with SQL SERVER 2008, even if the inserted recordsets are ordered, the queried results become disordered. You need to rely on ORDER BY to get an ordered result. For example, the following example:
SELECT * INTO # tables FROM sys.tables ORDER BY name; SELECT * FROM # tables
As shown above, SQL SERVER 2014 is disordered, and I wonder how it has become disordered since SQL SERVER 2012, which is like a black box to us. We only know that the result set has changed, but we don't know what internal changes have caused this phenomenon. The official Records not sorted in the table when using ORDER BY clause to insert data into Temp Table forum describes this issue as follows:
The official answer is not very clear, but there is no doubt that there must be a change in the internal storage or implementation of the temporary table, so that the data in the temporary table is no longer orderly by default, but SQL Server is not an open source database, and if the official documentation does not disclose these details, a lot of things will not know the real root cause!
If there is a special need to order the data in the temporary table, you can solve this problem by creating a clustered index. As follows:
SELECT * INTO # tables FROM sys.tables WHERE 1 = 0; CREATE CLUSTERED INDEX IDX_#tables_NAME ON # tables (name); INSERT INTO # tables SELECT * FROM sys.tables ORDER BY name; SELECT * FROM # tables
On how to sort temporary tables in SQL Server to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.