Groups | Blog | Home
all groups > sql server new users > october 2006 >

sql server new users : How can I tell what is locking my database?


Hilary Cotter
10/24/2006 8:25:10 AM
issue a sp_who2 and figure out what spid is blocking. Use DBCC
inputbuffer(SPID) to display the contents of the blocking process. SP_who2
should tell you the account which is doing the blocking and the hostname.

You can kill it by doing this Kill spid (replacing spid by the number
returned in sp_who2).

Blocking is normally considered to be a good thing as it protects data from
being modified in unpredictable ways. For example consider a multiuser
application handing ATM/banking transactions. If you and your wife both
withdraw your last 20 bucks at the same time and you don't have blocking,
both of you will get your last 20 bucks. If you do have blocking, as luck
will have it your wife will get the 20 bucks and you will either be
overdrawn, or get no money.

The problem you are seeing is probably due to poorly performing queries.
Study the procs, sql statements, and execution plans of them and rewrite
them for better performance or place indexes on the tables.

--
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.

This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com



[quoted text, click to view]

Vayse
10/24/2006 12:54:52 PM
Hi
I have a SQL Server db, with a Clients table. For some reason, I can't
update the Clients table from external apps. Also, I can't restore the db,
as I get a message that it is in use.
I've ran DBCC OPENTRAN and there are no open transactions.

Is there a way I can the user name of who is locking the database?
Also, is there a way of clearing any locks?
Thanks
Vasyse

Vayse
10/24/2006 2:55:45 PM
Thanks!

[quoted text, click to view]

AddThis Social Bookmark Button