惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
Intezer
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
N
News | PayPal Newsroom
T
Tenable Blog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
P
Privacy International News Feed
IT之家
IT之家
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
博客园_首页
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
NISL@THU
NISL@THU
I
InfoQ
D
DataBreaches.Net
有赞技术团队
有赞技术团队
K
Kaspersky official blog
Security Latest
Security Latest
The Register - Security
The Register - Security
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AI
AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic

博客园 - 流星啊。

vscode安装go所有插件 navicat15 for mysql激活 试用版SQL Server 2008 R2 提示评估期已过 常用SQL QQ web api Mysql数据库的分离和附加<转> Java字符串转换为日期和时间比较大小 Oracle中账户被锁定的解决方法 清除代码异味 EXT3.3在IE9上 , TreePanel click event 失效 在XP下配置自己的服务器IIS Extjs 树形设置选中 Window下删除SVN文件 GOF设计模式(转) ASCII表 博文阅读密码验证 - 博客园 查询最近10天要过生日的会员 Extjs中grid初始化时选中指定行的问题 - 流星啊。 - 博客园 C# 中ref out区别
sql 循环语句几种方式
流星啊。 · 2015-10-15 · via 博客园 - 流星啊。

--第一

declare @orderNum varchar(255)

create table #ttableName(id int identity(1,1),Orders varchar(255))

declare @n int,@rows int

insert #ttableName(orders) select orderNum from pe_Orders where orderId<50

--select @rows=count(1) from pe_Orders

select @rows =@@rowcount 

set @n=1 

while @n<=@rows

begin

select @orderNum=OrderNum from PE_Orders where OrderNum=(select Orders from #ttableName where id=@n)

print (@OrderNum)

select @n=@n+1

end

drop table #ttableName

--第二

declare @orderN varchar(50)--临时变量,用来保存游标值

declare y_curr cursor for --申明游标 为orderNum

select orderNum from pe_Orders where orderId<50

open y_curr --打开游标

fetch next from Y_curr into @orderN ----开始循环游标变量

while(@@fetch_status=0)---返回被 FETCH  语句执行的最后游标的状态,而不是任何当前被连接打开的游标的状态。

begin

print (@orderN)

update pe_Orders set Functionary+@orderN where orderNum=@orderN --操作数据库

fetch next from y_curr into @orderN --开始循环游标变量

end

close y_curr--关闭游标

deallocate y_curr --释放游标

--第三

select orderNum,userName,MoneyTotal into #t from pe_Orders po 

DECLARE @n int,@error int

--set @n=1 

set @error=0

BEGIN TRAN --申明事务

declare @orderN varchar(50),@userN varchar(50) --临时变量,用来保存游标值

declare y_curr cursor for  --申明游标 为orderNum,userName

select orderNum,userName from PE_Orders where Orderid<50

open y_curr

fetch next from y_curr into @orderN,@userN

while @@fetch_status = 0

BEGIN

select isnull(sum(MoneyTotal),0),orderNum from #t where username=@userN

-- set @n=@n+1

set @error=@error+@@error--记录每次运行sql后 是否正确  0正确

fetch next from y_curr into @orderN,@userN

END

IF @error=0

BEGIN

commit tran --提交

END

ELSE

BEGIN

ROLLBACK TRAN --回滚

END

close y_curr

deallocate y_curr

DROP TABLE #t

-------------------------------------------------------------

转自http://www.cnblogs.com/Luouy/archive/2012/05/11/2495394.html