[SQL] 只更新表中某一部分数据的实现方法

(1)只更新表中前10条数据(更新为固定值):

update BranchAccount
set AccountNumber = '10010'
from (select top 10 *from BranchAccountorder by ID)as t1
where BranchAccount.ID = t1.ID

(2)用一个表的字段值更新另一个表的某字段值:

update BranchAccount
set BranchAccount.AccountNumber = t1.AccountNumber
from TEMPBranchAccount as t1
where BranchAccount.ID = t1.ID

(3)更新表前10条数据(更新为另一个表的数据):

update BranchAccount
set BranchAccount.AccountNumber = t1.AccountNumber
from (select top 10 *from TEMPBranchAccount)as t1
where BranchAccount.ID = t1.ID


本文原创由`bluetata`发布于blog.csdn.net、转载请务必注明出处。


[SQL] 只更新表中某一部分数据的实现方法_第1张图片

你可能感兴趣的:([02],SQL,Server,[02],SQL-Com,Foundation)