SQL学习笔记
2009-11-18 12:51:46
限定处理记录的单位,rowcount=100表式每次处理100条数据。实际处理的记录数由rowcount和where子句决定。如果符合where的记录数大于rowcount,则有rowcount决定,如果小于rowcount,则由where决定。
create table tb(id int identity(1,1),num int)
insert into tb
values(1)
while @@identity<2000
begin
insert into tb
values(@@identity+1)
end
begin tran
set rowcount 100
delete from tb where id<300 只删除100条数据,处理的数量由rowcount决定
delete from tb where id<20 删除20条数据,处理的数量由where决定
set rowcount 0
rollback tran
select * from tb
相关文档:
--语 句 功 能
1、数据操作
Select --从数据库表中检索数据行和列
Insert & ......
交叉表语句的实现:
用于:交叉表的列数是确定的
select name,sum(case subject when '数学' then source else 0 end) as '数学',
sum(case subject when '英语' then source else 0 end) as '英语',
sum(case subject when '语文' then source else 0 end) as '语文'
from test
group by name ......
一
SQL重复记录查询(转自http://blog.csdn.net/RainyLin/archive/2009/02/17/3901956.aspx)
SQL重复记录查询
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select * from people
where peopleId in (select peopleId from people group ......