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.创建过程
create or replace procedure 过程名 as
声明语句段;
begin
执行语句段;
exception
异常处理语句段;
end;
2. 带参数的过程
参数类型3种
in参数:读入参数,主程序向过程传递参数值
out参数:输出参数,过程向主程序传递参数值
in out参数:双向参数
定义 ......
导入的详细流程
1、新建一个数据库
2、在新的数据库上点右键-》“所有任务”-》“导入数据库”,点下一步
3、什么都不要改,在数据库中选择那个旧的数据库,点下一步
4、在这个界面的数据库中选择你新建的数据库,点下一步
5、选择“在SQL SERVER数据库之间复制对象和数据”,点下一步
......
在SQL Server2005/2008中可以使用一下四个命令来调优sql语句以及检查调优的结果
set
statistics time on
set
statistics IO on
set
statistics profile on
set
statistics xml on
......
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语句,供大家参考……
--语 句 功 能
--数据操作
SELECT --从数据库表中检索数据行和列
INSERT --向数据库表添加新数据行
DELETE --从数据库表中删除数据行
UPDATE --更新数据库表中的数据
--数据定义
CREATE TABLE --创建一个数据库表
DROP TABLE --从数据库中删除表
A ......