473,394 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Tables get Locked

Hello

I have a stand alone Java application that uses SQL Server 2000 on the
same machine. Sometimes, when we run the applications and follow a
certain steps, the SQL server locks some of the table. At that point of
time, if we try to query Select * on those table, in Query Analyzer, it
just keep spinning and doesn't return anything. That tells me that the
tables are locked. If I close the application then it frees up the
connection and those tables are accessible again.
My question is how do I find out how and what query/update causes the
tables to be locked. Is there a tool (some kind of a profiler) that can
tell me what was the last insert/update/delete quesry was run before it
got locked?

Please help me.

Jul 23 '05 #1
2 3251
Yes, "sql profiler" comes with sql 2000. You can also look at the
current activity by executing the procedures sp_who2 and sp_lock.
sp_who2 shows the connections and if one is blocked by another process,
column "BlkBy". and sp_lock is more involved and will tell you the type
of locks and on what tables.
Just start sql profiler and then follow those "certain steps" you
mentioned to find the locking code.

-scott

Jul 23 '05 #2
Bardolator (Ba********@gmail.com) writes:
I have a stand alone Java application that uses SQL Server 2000 on the
same machine. Sometimes, when we run the applications and follow a
certain steps, the SQL server locks some of the table. At that point of
time, if we try to query Select * on those table, in Query Analyzer, it
just keep spinning and doesn't return anything. That tells me that the
tables are locked. If I close the application then it frees up the
connection and those tables are accessible again.
My question is how do I find out how and what query/update causes the
tables to be locked. Is there a tool (some kind of a profiler) that can
tell me what was the last insert/update/delete quesry was run before it
got locked?


For a convenient packaging of everything, you could try my aba_lockinfo,
see http://www.sommarskog.se/sqlutil/aba_lockinfo.html

But note that the problem may be more complex than just looking at
currently executing queries. Improper error handling or similar can
have left a process with a stray transaction.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff Roughgarden | last post by:
Does anyone know how to identify the hottest, most active tables in a database? We have hundreds of users hitting a PeopleSoft database with hundreds of tables. We are I/O bound on our SAN, and...
0
by: Matthew Wells | last post by:
Good morning... I have an Access front end that uses SQL Server linked tables. SQL Server uses Windows authentication. I have one Windows group that all Access users are a member of. I added...
0
by: CaptainMcBunnyTickle | last post by:
Using FLUSH TABLES via the C query API mysql_query() hangs if the table is locked already. That is to say, nothing prevents me from running a LOCK TABLES twice; it won't tell me "it's already...
13
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any...
2
by: Matthew Wells | last post by:
Good morning... I have an Access front end that uses SQL Server linked tables. SQL Server uses Windows authentication. I have one Windows group that all Access users are a member of. I added...
7
by: Mathew Butler | last post by:
I'm investigating an issue I have when pulling data back from MS access I'm retrieving all rows from a column in a table of 5000 rows - accessing a column of type "memo" ( can be 65353 character...
1
by: pemigh | last post by:
I'm almost done with an application, and trying to lock it down tightly. But I still want users to be able to point to a new location for the data file. The code below fires off to detect and...
5
by: breal | last post by:
I have a db table that holds a list of ports. There is a column in_use that is used as a flag for whether the port is currently in use. When choosing a port the table is read and the first...
0
by: sparks | last post by:
I was using this to swap out a form with subforms on it by just making a copy and tying each to copy of the same table. subformV1 tblVisit1 subformV2 tblVisit2 etc Select Case TabCtl0.Value...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.