关于SQL Server的WITH(NOLOCK)和(NOLOCK)
The difference is that you should be using the syntax WITH (NOLOCK)
(or WITH (<any table hint>)
). Why?
-
Without
WITH
is deprecated. From Table Hints on MSDN:Omitting the WITH keyword is a deprecated feature: This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
-
from table1 nolock
does not apply a hint at all - that's an alias. For example:SELECT nolock.name FROM sys.objects nolock ORDER BY nolock.name;
Notice that I can use
nolock
as an alias. No hint is applied here. -
from table1 as mytable nolock
is invalid syntax in modern versions of SQL Server.Msg 1018, Level 15, State 1, Line 12
Incorrect syntax near 'nolock'. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See SQL Server Books Online for proper syntax.
相关文章
- sql server中sa身份能登录,window身份登录不了
- C# 连接SQL Server数据库的几种方式--server+data source等方式
- SQL Server Replication 中关于视图的点滴
- windows Server 2008 R2 TFS2010的备份
- Windows Server 2016 部署AD域控制器
- [SQL] sql server中如何查看执行效率不高的语句
- SQL Server 2005 常用数据类型详解
- SQL Server 取前一天的0点和23点59分59秒
- SQL SERVER全面优化-------Expert for SQL Server 诊断系列
- SQL SERVER服务器链接连接(即sql server的跨库连接)
- SQL Server 2005 安装图解(图文详解+全程截图)
- Sql Server substring(expression, start, length)函数
- SQL SERVER服务器链接连接(即sql server的跨库连接)
- SQL SERVER服务器链接连接(即sql server的跨库连接)
- SQL Server 中关于EXCEPT和INTERSECT的使用方法
- MySQL Server 安装失败
- SQL Server SQL脚本