Solved

get history of locks?

Posted on 2014-10-21
8
90 Views
Last Modified: 2014-10-22
is it possible to get dates of when last data locks happened on select queries?
0
Comment
Question by:25112
  • 3
  • 3
  • 2
8 Comments
 
LVL 5

Author Comment

by:25112
ID: 40394642
I checked master.syslockinfo but it does not have any date, but some binary data.

also master.dbo.syslockinfo  is bringing different count than master.sys.syslockinfo. i am assuming lock info is captured per db specific.
0
 
LVL 47

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 300 total points
ID: 40394794
You can't since the available information it's in general a snapshot of what's going on at the moment.
The only way it's to create a database where you can keep all those information for later verification.
0
 
LVL 69

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 200 total points
ID: 40394799
The new view is sys.dm_tran_locks.  But you won't find datetime.  I suspect that would be just too much overhead to keep up with.  When SQL gets busy, locks are taken and released at a huge rate, so trying to time stamp all of them would be too damaging to performance.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 5

Author Comment

by:25112
ID: 40394867
OK, what I get is that unless i profile(r), i cant capture past locks..

then, is there any value to this query, now:
select * from master.dbo.syslockinfo a join master.dbo.sysprocesses b on a.req_spid=b.spid where object_name(a.rsc_objid) is not null
0
 
LVL 69

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 200 total points
ID: 40394868
Hmm, I don't really know.  I haven't used those obsolete views in years, so I'm not familiar with them any more.
0
 
LVL 47

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 300 total points
ID: 40394892
That query only works if when you run it the lock still exists. If not, will return nothing.
Like I told you that's only work as snapshot not with stored information. For that you need to create your own monitoring tool or use one as SCOM or another one similar.
0
 
LVL 47

Accepted Solution

by:
Vitor Montalvão earned 300 total points
ID: 40394905
Here's an article how to create your own monitoring tool for deadlocks.
0
 
LVL 5

Author Comment

by:25112
ID: 40396669
thank you
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

774 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question