xuyangus 发表于 2018-10-14 14:29:50

查询SQL Server system session ID?

  今天在论坛看到一篇文章问到为什么SQL Server系统的SESSION>  在2005之前查询用户会话使用:
  select * from sysprocesses wherespid < 50
  但是在SQL Server 2005之后已经没有这个限制了,我在MSDN上找到了下面这篇文章:How It Works: System Sessions
  Looking at a SQL Server error log it is formatted with the date, time and session>. Many of the>s following the spid value.
  2008-01-08 20:03:36.12 spid5s

  The s indicates that the session is a system session. Prior to SQL Server 2005 all system sessions were limited to session>
  Instead of the older &quot;select * from sysprocesses where spid < 50&quot; you should use &quot;select * from sys.dm_exec_sessions where is_user_process = 0&quot; to>
  根据上面的讲法系统Session>  select * from sys.dm_exec_sessionswhereis_user_process = 1
  is_user_process
  bit
  如果会话是系统会话,则为 0。否则,为 1。不可为空值
  更多信息参考:http://msdn.microsoft.com/zh-cn/library/ms176013(v=sql.90).aspx

页: [1]
查看完整版本: 查询SQL Server system session ID?