-
存储过程
- 一个简单存储过程例子
- CREATE PROCEDURE sp_cpsum_bylevel1 AS
- begin
- declare @code varchar(50)
- declare @num varchar(50)
- declare @command varchar(1000)
- declare cursor_tmp_1 cursor for select left(ypcode,2),count(left(ypcode,2)) from cpname where ylevel=3 group by left(ypcode,2)
- open cursor_tmp_1
- fetch next from cursor_tmp_1 into @code, @num
- while @@fetch_status = 0
- begin
- set @command = 'update cpname set shuliang ='''+ @num + ''' where ycode ='''+ @code +''' and ylevel=1'
- print @command
- EXEC (@command)
- fetch next from cursor_tmp_1 into @code, @num
- end
- close cursor_tmp_1
- deallocate cursor_tmp_1
- end
-
- GO
- 执行 exec sp_cpsum_bylevel1
-
相关阅读:
Docker--使用
腾讯云发送短信
Mysql--查询基础
flask10--数据库链接池(通用),wtforms
Flask11--Flask-script,sqlalchemy
序列化 json
第五章-算术运算符
计算机网络自顶向下的方法-第二章 应用层
第三章-数据类型
第三章-常量和宏定义
-
原文地址:https://www.cnblogs.com/beijingstruggle/p/4904880.html
Copyright © 2020-2023
润新知