下面这个存储过程是实现将表t_jxjh_ydjxrws中满足条件的数据添加到表t_jxrws中
CREATE
PROCEDURE
jxjh_sczxjxrws
@xnxqbh varchar ( 5 ),
@zybh varchar ( 10 ),
@ccbh varchar ( 10 ),
@nj int
AS
declare @li_bjs int
declare @ls_kc varchar ( 100 )
declare @li_zks int
declare cur_1 cursor for select bjs,kc,zks from t_jxjh_ydjxrws where xnxqbh = @xnxqbh and zybh = @zybh and ccbh = @ccbh and nj = @nj -- 定义游标
open cur_1 -- 打开游标l
fetch next from cur_1 into @li_bjs , @ls_kc , @li_zks -- 取第1条记录
while @@fetch_status = 0 -- 循环读取剩余记录
begin
insert into t_jxrws(xnxqbh,zybh,ccbh,nj,bjs,kc,zks) values ( @xnxqbh , @zybh , @ccbh , @nj , @li_bjs , @ls_kc , @li_zks )
fetch next from cur_1 into @li_bjs , @ls_kc , @li_zks
end
GO
@xnxqbh varchar ( 5 ),
@zybh varchar ( 10 ),
@ccbh varchar ( 10 ),
@nj int
AS
declare @li_bjs int
declare @ls_kc varchar ( 100 )
declare @li_zks int
declare cur_1 cursor for select bjs,kc,zks from t_jxjh_ydjxrws where xnxqbh = @xnxqbh and zybh = @zybh and ccbh = @ccbh and nj = @nj -- 定义游标
open cur_1 -- 打开游标l
fetch next from cur_1 into @li_bjs , @ls_kc , @li_zks -- 取第1条记录
while @@fetch_status = 0 -- 循环读取剩余记录
begin
insert into t_jxrws(xnxqbh,zybh,ccbh,nj,bjs,kc,zks) values ( @xnxqbh , @zybh , @ccbh , @nj , @li_bjs , @ls_kc , @li_zks )
fetch next from cur_1 into @li_bjs , @ls_kc , @li_zks
end
GO
CREATE PROCEDURE jxjh_sczxjxrws
@xnxqbh varchar(5),
@zybh varchar(10),
@ccbh varchar(10),
@nj int
AS
AS之前的这段用于声明调用存储过程时需要传递的参数!每个参数后面必须用逗号分隔。
AS
declare @li_bjs int
declare @ls_kc varchar(100)
declare @li_zks int
AS之后的这段的变量声明用于在程序中使用!
在asp.net页面中调用存储过程(这里是在类中实现的)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/1327ab569c1ae82736693a50b8e33378.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/7ff8d92cded7e0ce15e7ca1acc870052.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/717446ca04a6125dc5b6b54e0fa14ab4.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/0196c3df5ea9e936f21e9932cca91014.gif)