How does sql server sort your data?

后端 未结 4 589
失恋的感觉
失恋的感觉 2020-11-28 15:31

I was wondering how sql server sorts it\'s data. I noticed that if I have a table that doesn\'t contain the column \"Id\" and you select data without \"ORDER BY\" sql server

4条回答
  •  無奈伤痛
    2020-11-28 15:53

    I had a similar experience with SQL Server returning results sorted differently than I expected. I found that if you specify a table hint in the select statement, giving the name of the clustered index, you get the results ordered how you want:

    select * from test_order WITH (INDEX([ClusteredIndexName]))
    

提交回复
热议问题