sql server学习笔记

2014-11-24 11:14:22 · 作者: · 浏览: 0

sql server学习笔记
一共有两点
一 : 往 数据库中插入记录的Insert 语句后的union all 的作用
例如有这么几条语句:
insert into Salary(HrName,Monthly,[Money])
select '张三','一月','3000'
union all
select '张三','二月','3200'
union all
select '张三','三月','3500'
www.2cto.com
语句中的union all的作用就是就是通过一个select查询的结果集完成一次性的多行插入。两个union all 把三条记录一次性插入表中
二 : 在用update语句更新数据库中的记录时报错,无法绑定由多个部分组成的标识符的问题的解决方法
正确的update语句如下:
update charge set charge.ch_electricity_money=coust.co_electricity*2.50,
charge.ch_water_money=coust.co_water*1.20
from charge,coust ----------不加这句就会报错
where coust.ho_id=charge.ho_id
作者 秋之白桦