How to maintain the order of insertion in SQL Server

前端 未结 2 570
抹茶落季
抹茶落季 2020-12-11 13:31

I am just wondering if I can maintain the order of insertion of data in SQL Server?

I am working on my own project and it is kind of blog site having a number of pos

2条回答
  •  無奈伤痛
    2020-12-11 13:36

    When you specify ORDER BY in an INSERT...SELECT statement, SQL Server will assign IDENTITY values in the order specified. However, that does not mean rows are necessarily inserted in that order.

    If you need rows returned in a specific order, you must use ORDER BY to guarantee ordering. Indexes can be leverage provide order data efficiently depending on the query particulars.

提交回复
热议问题