SQL server 批量插入和更新数据

批量插入数据

insert into A表数据库名.[dbo].A(a,b,c)
(select a,b,c from B表数据库名.[dbo].B)

批量更新数据

根据身份证第二位更新性别
update Person set
Sex = case SUBSTRING(ID_Num,17,1)%2 when 1 then '男' else '女' end from Person

错误写法

update Person set
Sex = (select case SUBSTRING(ID_Num,17,1)%2 when 1 then '男' else '女' end from Person)
报错:子查询返回的值不止一个

上一篇:Python练手例子(14)


下一篇:gem install redis报错解决