Retain The Order while Insert Rows

2019-06-11 09:32发布

I put a sort component to sort my data. and the data was sorted. but my destination table is unordered!

How can retain the Order of sorted rows while Inserting them into sql Table with ssis?

标签: ssis
2条回答
等我变得足够好
2楼-- · 2019-06-11 10:34

There is no inherent ordering of rows in a SQL Server table. You'll need to either add a 'sort order' column or write your queries so that they produce properly sorted result sets.

You can use an IDENTITY column as your 'sort order' columns, since it will increment as things get inserted.

Understand that repeated executions of a given query against a sql database are specifically not guaranteed to return results in the same order, so your queries need to do it each and every time.

查看更多
做个烂人
3楼-- · 2019-06-11 10:35

Rows in a relational database do not have any "order" - they are like water molecules in a bucket! If you need to have an order then you must include another column that you can use to order by - e.g. an autoincrement field, a timestamp, or some column from external data. You can then use that column to order your data when you query it - otherwise you won't get ordered data.

查看更多
登录 后发表回答