易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

PL/SQL学习笔记五


游标是从数据库中提取出来的数据,以临时表的形式存放在内存中,在游标中有一个数据指针,在初始状态下指向首记录, 利用fetch语句移动该指针,从而对游标中的数据进行各种操作。
1.定义游标
cursor 游标名 is select语句;
2.打开游标
open 游标名;
3.提取游标数据
fetch 游标名 into 变量名1, 变量名2, ....;
或 ......

SQL触发器

一个简单的小实例就明白~!
 user表
在这张表中建立触发器  
 Create   trigger   tiggername  
 on   user     
 for   delete     
 as   
 begin ......

使用set statistics on 来检查sql tuning的结果


在SQL Server2005/2008中可以使用一下四个命令来调优sql语句以及检查调优的结果
set
 statistics time on

set
 statistics IO on

set
 statistics profile on

set
 statistics xml on

......

Sql 查询当天、本周、本月记录

Sql代码:Powered by chenjiazi
--查询当天:   
select * from info where DateDiff(dd,datetime,getdate())=0   
  
--查询24小时内的:   
select * from info where DateDiff(hh,datetime,getDate())<=24   
  
--info为表名,datetime为数 ......

SQL重复记录查询删除

1
、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select

*

from
people
where
peopleId
in
(
select
   peopleId  
from
   people  
group
  
by
   peopleId  
having
  
cou ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号