T-SQL 批量更新字段
;WITH IdPhone AS ( SELECT * FROM(VALUES ('6205021','13680011913'), ('4401061','13680000972'), ('3729281','13680011766'), ('1310221','13680001061'), ('4128251','13680015512'), ('3706251','13680005269'), ('5102121','13680017619'), ('4412831','13680017760'), ('4209821','13680013534'), ('4413231','13680009467') ) AS v(Id, Phone) ) SELECT * FROM IdPhone;
更新
WITH IdPhone AS ( SELECT * FROM ( VALUES('6205021', '13680011913'), ('4401061', '13680000972'), ('3729281', '13680011766'), ('1310221', '13680001061'), ('4128251', '13680015512'), ('3706251', '13680005269'), ('5102121', '13680017619'), ('4412831', '13680017760'), ('4209821', '13680013534'), ('4413231', '13680009467') ) AS v(Id, Phone) ) --SELECT DISTINCT u.Id--,v.Phone UPDATE u SET u.StaffId = v.Phone FROM dbo.Users AS u WITH(NOLOCK) INNER JOIN IdPhone AS v ON v.Id = u.IDNumber ;
posted on 2019-07-19 19:43 Aidou_dream 阅读(548) 评论(0) 编辑 收藏 举报