SQL Server提供了sys.dm_tran_locks這個DMV來查看當前資料庫中的鎖,前面的圖2就是通過這個DMV來查看的,資料庫鎖的手段不外乎兩種:
使用sys.dm_tran_locks這個DMV
以下的例子語法是來提取需要的鎖信息:
SELECT str(request_session_id, 4, 0) AS spid,
convert (varchar(20), db_name(resource_database_id))
AS DB_Name,
case when resource_database_id =
db_id() and resource_type = 'OBJECT'
then convert(char(20), object_name(resource_Associated_Entity_id))
else convet(Char(20), resource_Associated_Entity_id)
end as object,
convert(varchar(12), resource_type) AS resrc_type,
convert(varchar(12), resource_type) AS req_type,
convert(char(3), request_mode) AS mode,
convert(varchar(8), request_status) AS status
from sys.dm_tran_locks
order by request_session_id, 3
desc
-雲遊山水為知已逍遙一生而忘齡- 電腦神手
...
回覆刪除else convet(Char(20), resource_Associated_Entity_id)
...
==> convert
我打錯字了,謝謝你(這證明我親手key的語法)。
回覆刪除