什么是
存储过程(stored procedure)是一组为了完成特定功能的sql语句集,是利用sql server所提供的transact-sql语言所编写的程序。经编译后存储在中。存储过程是数据库中的一个重要对象,用户通过指定存储过程的名字并给出参数(如果该存储过程带有参数)来执行它。存储过程是由流控制和sql语句书写的过程,这个过程经编译和优化后存储在数据库服务器中,存储过程可由应用程序通过一个调用来执行,而且允许用户声明变量 。同时,存储过程可以接收和输出参数、返回执行存储过程的状态值
存储过程语法
create procedure [拥有者.]存储过程名[;程序编号] [(参数#1,…参数#1024)] [with {recompile | encryption | recompile, encryption} ] [for replication]
看一个简单的实例
网趣购物系统静态版支持网站一键静态生成,采用动态进度条模式生成静态,生成过程更加清晰明确,商品管理上增加淘宝数据包导入功能,与淘宝数据同步更新!采用领先的AJAX+XML相融技术,速度更快更高效!系统进行了大量的实用性更新,如优化核心算法、增加商品图片批量上传、谷歌地图浏览插入等,静态版独特的生成算法技术使静态生成过程可随意掌控,从而可以大大减轻服务器的负担,结合多种强大的SEO优化方式于一体,使
0
create procedure order_tot_amt @o_id int, @p_tot int output as select @p_tot = sum(unitprice*quantity) from orderdetails where ordered=@o_id go
下面来看一个利用存储过程批量导入数据实例
declare @mycounter int
set @mycounter = 0 /*设置变量*/
while (@mycounter begin
waitfor delay '000:00:10' /*延迟时间10秒*/
insert into time_by_day
(time_id, the_date, the_year, month_of_year, quarter, day_of_month)
select top 1 time_id + 1 as time_id, the_date + 1 as the_date, year(the_date + 1)
as the_year, month(the_date + 1) as month_of_year, { fn quarter(the_date + 1)
} as quarter, day(the_date + 1) as day_of_month
from time_by_day
order by time_id desc
set @mycounter = @mycounter + 1
end
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号