SQL Server System Session ID是不是1-50?

來源:互聯網
上載者:User

今天在論壇看到一篇文章問到為什麼SQL Server系統的SESSION ID是從1到50的,以前看過文章,這些Session是SQL Server為了運行系統活動比如((lazy writer, ghost record cleanup, DTC commit/abort),所以會保留50 Session ID給SQL Server使用,使用者會話從51開始。

 

在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 identifier.   Many of the identifiers contain 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 ids less than 50.  SQL Server 2005 lifted that restriction.   In order identify a session performing system actives
(lazy writer, ghost record cleanup, DTC commit/abort, ...) the sessions are identified as system sessions.

Instead of the older "select * from sysprocesses where spid < 50" you should use "select * from sys.dm_exec_sessions where is_user_process = 0" to identify system processes.

 

根據上面的講法系統Session ID有可能超過50,所以查詢使用者Session ID使用

 

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

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.