码迷,mamicode.com
首页 > 数据库 > 详细

T-SQL 批量更新字段

时间:2019-07-19 20:27:02      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:http   update   tin   lock   src   图片   mamicode   span   user   

;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 ;

 

T-SQL 批量更新字段

标签:http   update   tin   lock   src   图片   mamicode   span   user   

原文地址:https://www.cnblogs.com/Jolinson/p/11215399.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!