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

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - litsword

[转]IDENT_CURRENT、SCOPE_IDENTITY、@@IDENTITY 差異對照表 [转贴]TFS Power Tools–September 2010 Release SQL 中使用正则表达式过滤字母或数字 [转载]记不住ASP.NET页面生命周期的苦恼 Split Full Name as First and Last HTML 合并单元格示例 动态加载配置文件 [转载]实现PadLeft的SQL脚本 Useful SQL script 在Update 和 Delete语句中使用 Inner Join SQL Date Time format SCOPE_IDENTITY、IDENT_CURRENT 和 @@IDENTITY 的区别 Union合并数组(去掉重复的项目) Winform 版本信息 Sql语句 生日提醒 事件的定义 【原创】RSS开发心得小结 SQL数据类型nchar,char,varchar与nvarchar区别 JavaScript里面三个等号和两个等号的区别
SQL游标遍历时的变量赋值
litsword · 2011-10-14 · via 博客园 - litsword

今天遇到一个错误,自己一直没有意思到这样写是错误的。

在游标循环过程中使用变量要注意

declare @a;

select @a = column1 from table1 where column2 = '123'

if @a is null

begin

end

原以为如果找不到'123'的记录,变量@a 会被赋成null,可事实上,@a 会保留上一次loop取到的有效值(即非null的历史值)

应该改为

set @a = select column1 from table1 where column2 = '123'

这样才能在找不到记录时正确将@a设置为null....