gpt4 book ai didi

sql - SQL Server中 '@@'的用法是什么

转载 作者:行者123 更新时间:2023-12-02 12:16:01 25 4
gpt4 key购买 nike

@@ 在 SQL Server 中的用法是什么?

最佳答案

According to MSDN ,它们的正确名称是系统函数

命名困惑(全局变量、系统函数、全局函数)源于 SQL Server 历史中使用的不同术语。来自 MSDN Transact-SQL Variables article :

The names of some Transact-SQL system functions begin with two at signs (@@). Although in earlier versions of Microsoft SQL Server, the @@functions are referred to as global variables, they are not variables and do not have the same behaviors as variables. The @@functions are system functions, and their syntax usage follows the rules for functions.

因此,两个“at”符号(@@)用于表示某些系统函数。不推荐使用短语“全局变量”(尽管您仍然会看到 some people use it ),很可能是因为在编程世界中,全局变量是随处可见的单个值,并且正如已经指出的那样,它不是这里发生了什么(例如,@@IDENTITY)。

临时表的命名方式可能会导致进一步的困惑。表名前面的单个井号表示本地范围的临时表(例如,#MyLocalTable),就像单个 at 符号表示本地范围的变量(例如,@MyLocalVariable)。向临时表添加第二个哈希符号使其具有全局范围(例如,##MyGlobalTable),但尝试向变量 does not produce the same effect 添加两个 at 符号。

关于sql - SQL Server中 '@@'的用法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29671417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com