---实例DB:AdventureWorks2014

--- 创建view DBLocks

USE [AdventureWorks2014]
GO

/****** Object:  View [dbo].[DBlocks]    Script Date: 8/17/2016 6:38:16 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE VIEW [dbo].[DBlocks] AS
SELECT request_session_id as spid,
db_name(resource_database_id) as dbname,
CASE
WHEN resource_type = 'OBJECT' THEN
object_name(resource_associated_entity_id)
WHEN resource_associated_entity_id = 0 THEN 'n/a'
ELSE object_name(p.object_id)
END as entity_name, index_id,
resource_type as resource,
resource_description as description,
request_mode as mode, request_status as status
FROM sys.dm_tran_locks t LEFT JOIN sys.partitions p
ON p.partition_id = t.resource_associated_entity_id
WHERE resource_database_id = db_id();
GO
View Code

相关文章:

  • 2021-11-01
  • 2021-11-07
  • 2021-08-24
  • 2022-12-23
  • 2021-05-17
  • 2021-05-20
猜你喜欢
  • 2022-12-23
  • 2022-01-17
  • 2021-12-24
  • 2021-10-17
  • 2022-01-14
相关资源
相似解决方案