Avatar of bmsande
bmsande

asked on 

SQL Server - reporting on locked tables

We have an Enterprise Content Mgmt app connected to SQL 2008 R2.  Lately we've encountered locked tables.  Is it possible to run historical reports on previous locks, or can this only be obtained at the time the table is locked?

I'm aware of sp_who2 but as far as I know that's only helpful at the time of the lock.  We're trying to gather information on performance issues from last week.

Thanks in advance.
Microsoft SQL ServerMicrosoft SQL Server 2008Databases

Avatar of undefined
Last Comment
Vitor Montalvão
Avatar of chaau
chaau
Flag of Australia image

You can use the xp_readerrorlog. I recommend you use a temp table:
CREATE TABLE #Errors 
  ( 
     Logdate VARCHAR(23),ProcessInfo VARCHAR(12),MsgText VARCHAR(3000) 
  ) 

INSERT #Errors 
EXEC xp_readerrorlog 
  0 

INSERT #Errors 
EXEC xp_readerrorlog 
  1 

INSERT #Errors 
EXEC xp_readerrorlog 
  2 

CREATE INDEX idx_temp1 
  ON #Errors(Logdate /* , MsgText */) 

select * FROM #Errors WHERE CAST(Logdate as DATETIME) >= GETDATE() - 7

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Is it possible to run historical reports on previous locks, or can this only be obtained at the time the table is locked?
It's only possible when it happens unless you have some kind of monitoring tool active (SCOM for example) or a profiler running constantly on the instance.
Do you know when the locks usually happens? If so you can set a trace to run during that period to try to capture the locks.
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo