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

推荐订阅源

CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security
WordPress大学
WordPress大学
博客园_首页
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
The Cloudflare Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tenable Blog
Google Online Security Blog
Google Online Security Blog
PCI Perspectives
PCI Perspectives
博客园 - 三生石上(FineUI控件)
Recent Commits to openclaw:main
Recent Commits to openclaw:main
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
Forbes - Security
Forbes - Security
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Security Latest
Security Latest
小众软件
小众软件
T
The Exploit Database - CXSecurity.com
C
Cisco Blogs
量子位
P
Privacy & Cybersecurity Law Blog
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
C
Cyber Attacks, Cyber Crime and Cyber Security
Scott Helme
Scott Helme
Cisco Talos Blog
Cisco Talos Blog
S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
N
News and Events Feed by Topic
U
Unit 42
腾讯CDC
博客园 - 聂微东
博客园 - 【当耐特】
B
Blog
P
Proofpoint News Feed
B
Blog RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - 旴江老段

委托和事件的区别 如何开发和维能hold住全场的软件 什么样的软件才能hold住全场 SNOOP 开发WPF的好工具 被遗忘的事物 前台线程和后台线程(Foreground and Background Threads) runtime binding policy Checking space used in a database AsyncCallback方法和主线程怎么同步呢? Remoting Practice Sample Using Custom Assemblies with Reports 为什么32位的CPU?为什么32位的CPU只能支持4G的内存呢? 学习SSL和certificate的好网页 Wix Upgrade怎么判断是否更新 学WIX的好网站 sql server try catch and transaction的几个要点 使SQL关键字变大写的小工具 Assert.AreEqual .net 异步调用机制
SELECT @local_variable (Transact-SQL)
旴江老段 · 2009-04-01 · via 博客园 - 旴江老段

先想想select @a 都会返回什么值。

use AdventureWorks
go

declare @a varchar
select @a
select @a = 'a' from Production.Culture where 1 = 2
select @a
select @a = 'b'
select @a
select @a = 'a' from Production.Culture where 1 = 2
select @a

在看看MSDN的解释

Remarks

SELECT @local_variable is typically used to return a single value into the variable. However, when expression is the name of a column, it can return multiple values. If the SELECT statement returns more than one value, the variable is assigned the last value that is returned.

If the SELECT statement returns no rows, the variable retains its present value. If expression is a scalar subquery that returns no value, the variable is set to NULL.

One SELECT statement can initialize multiple local variables.