sqlserver中游标的使用
来源:互联网 发布:便携音箱推荐 知乎 编辑:程序博客网 时间:2024/05/19 02:06
select * into #strSplit from dbo.Fun_SplitStr(@fsqlstr,'|') --把字符串参数按'|'分隔,存进临时表
--游标遍历结果集的result列数值,并且赋值给fcode,显示,先把字符串分为表名,列名
declare MyCur cursor for select result from #strSplit --定义游标,对临时表的某一列进行遍历
open mycur --打开游标
fetch next from mycur into @fcode --分隔后的字符串遍历
while @@fetch_status=0 --判断是否还有数据
begin
if left(@fcode,1) = '2' begin exec(@tSQL) end --对里面的字符进行逻辑处理
else if left(@fcode,1) = '1' begin --判断是否为1开头字符串
set @strtle = substring(@fcode,2,LEN(@fcode)) --返回去除掉第一个的字符串
end
else begin set @strcol = @fcode --不是1开头的字符串
end
fetch next from mycur into @fcode --抓取下一个
end
close mycur --关闭游标
deallocate mycur --释放游标
--游标遍历结果集的result列数值,并且赋值给fcode,显示,先把字符串分为表名,列名
declare MyCur cursor for select result from #strSplit --定义游标,对临时表的某一列进行遍历
open mycur --打开游标
fetch next from mycur into @fcode --分隔后的字符串遍历
while @@fetch_status=0 --判断是否还有数据
begin
if left(@fcode,1) = '2' begin exec(@tSQL) end --对里面的字符进行逻辑处理
else if left(@fcode,1) = '1' begin --判断是否为1开头字符串
set @strtle = substring(@fcode,2,LEN(@fcode)) --返回去除掉第一个的字符串
end
else begin set @strcol = @fcode --不是1开头的字符串
end
fetch next from mycur into @fcode --抓取下一个
end
close mycur --关闭游标
deallocate mycur --释放游标
0 0
- sqlserver中游标的使用
- SqlServer中游标的使用
- sqlserver中游标的使用
- Sqlserver中游标的用法
- SQL中游标的使用
- ORACLE 中游标的使用
- SQL中游标的使用
- oracle中游标的使用
- oracle中游标的使用
- Oracle 中游标的使用
- Oracle中游标的使用
- MySQL中游标的使用
- sql中游标的使用
- 数据库中游标的使用
- SQL中游标的使用
- 数据库中游标的使用
- SQL中游标的使用
- MySQL中游标的使用
- String类型编译器优化
- HDU 1250 Hat's Fibonacci
- Sqoop详解
- python网络爬虫入门(三)—— 做个简陋的pixabay 图片下载器
- RESTful风格例子
- sqlserver中游标的使用
- Oracle查询某一列的重复部分
- QT系列:获取系统时间 日期时间格式
- c语言指针的典例
- 解决手机端页面的鼠标点击出现蓝色背景
- 快递100物流查询接口的实现
- ubuntu gcc 降级和升级
- 给定数组求二叉查找树并返回高度
- tcp(二)---多进程TCP