使用SQL Server 2008中的多行值更新多行 [英] Update multiple rows with multiple rows value in sql server 2008
问题描述
大家好.
我想更新具有不同值的多行,这些值是从同一张表的前n行中检索到的.在这里的示例可以使画面更清晰.
Loc_code | Loc_Row
-------- --------
1 | R1
2 | R2
3 | R3
4 | R4
5 | R5
而且我想将前5个Loc_Row值复制到Loc_Row中,并且Loc_Code在6到10之间
Loc_code | Loc_Row
-------- --------
6
7
8
9
10
可能吗?谢谢.
Hye all..
I want to update multiple rows with different values which I retrieve from top n rows in the same table. Here the example to give a clearer picture.
Loc_code | Loc_Row
-------- --------
1 | R1
2 | R2
3 | R3
4 | R4
5 | R5
And i want to copy Top 5 Loc_Row values into Loc_Row with Loc_Code between 6 and 10
Loc_code | Loc_Row
-------- --------
6
7
8
9
10
Is it possible? Thanks.
推荐答案
INSERT INTO myTable
SELECT TOP(5) 5+Loc_code, Loc_Row
FROM myTable
这篇关于使用SQL Server 2008中的多行值更新多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!