How to join two tables together with same number of rows by their order

前端 未结 9 1967
庸人自扰
庸人自扰 2020-12-19 04:38

I am using SQL2000 and I would like to join two table together based on their positions

For example consider the following 2 tables:

table1
-------
name
-         


        
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 05:02

    Do you have anything that guarantees ordering of each table?

    As far ax I know, SQL server does not make any promise on the ordering of a resultset unless the outer query has an order by clause. In your case you need Each table to be ordered in a deterministic manner for this to work.

    Other than that, in SQL 2000, as answered before me, a temp table and two cursors seem like a good answer.

    Update: Someone mentioned inserting both tables into temp tables, and that it would yield better performance. I am no SQL expert so I defer to those who know on that front, and since I had an up-vote I thought you should investigate those performance considerations. But in any case, if you do not have any other information in your tables than what you showed us I'm not sure you can pull it off, ordering-wise.

提交回复
热议问题