Sql Server根据记录集批量更新数据库
update t1 set t1.value=t2.value from t2 where t1.id=t2.id
update jbsite_class set topicnum = count
from (select t2.classid,count from (
select distinct classid,count(*) as count
from jbsite_product
group by classid) t2
inner join jbsite_product on jbsite_product.id = t2.classid
) b where jbsite_class.id=b.classid
相关文档:
(1) 选择最有效率的表名顺序(只在基于规则的优化器中有效):
ORACLE 的解析器按照从右到左的顺序处理from子句中的表名,from子句中写在最后的表(基础表 driving table)将被最先处理,在from子句中包含多个表的情况下,你必须选择记录条数最少的表作为基础表。如果有3个以上的表连接查询, 那就需要 ......
在SQL Server2005/2008中可以使用一下四个命令来调优sql语句以及检查调优的结果
set
statistics time on
set
statistics IO on
set
statistics profile on
set
statistics xml on
......
本文总结了开发工作中常用的SQL语句,供大家参考……
--语 句 功 能
--数据操作
SELECT --从数据库表中检索数据行和列
INSERT --向数据库表添加新数据行
DELETE --从数据库表中删除数据行
UPDATE --更新数据库表中的数据
--数据定义
CREATE TABLE --创建一个数据库表
DROP TABLE --从数据库中删除表
A ......
D:\projects\openi\misc\xxxx_data_20090828>bcp [xxxxolap].[dbo].[wdb_cxbz] in wdb_xxx.txt -c -T
SQLState = 37000, NativeError = 4060
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database "xxxolap" requested by the login. The login failed.
S ......
1
、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select
*
from
people
where
peopleId
in
(
select
peopleId
from
people
group
by
peopleId
having
cou ......