Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 why it is locking an update query ?

Author  Topic 

ann06
Posting Yak Master

171 Posts

Posted - 2012-02-22 : 09:04:37
hi,
when i open a table in sql manager using select * from table 1
iam unable to run update query for a record if the table is still open in enterprise manager until i close it will run.

but, i tried for different table in different db iam able to update a record on a table while the table is open in Enterprise manager.

can any body explain why in first case its is blocked while in second case its running? is this a configuration issue?
thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-22 : 09:35:32
is the select run under a transaction?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-22 : 09:40:05
do sp_lock and sp_who2 to see what's going on

No Miracles..something ELSE is going

AFAIK...SSMS or EM does not lock the results

Can you list out all the steps you do that causes this problem so we san try to replictae it?

Step 1. I open SSMS
Step 2. I do...



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-22 : 10:04:19
once you get locking process ID (if one exists) you can check what command that process is executing by using below command

DBCC inputbuffer(<ProcessID>

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2012-02-23 : 00:51:43
-->visakh: no its not running under a transaction its running under right click/open table/return all rows
steps are
-->X002548:
1. in ssms i right click the table mail_sent return all rows it run and displays the result (select * from mail_sent)
2. in query analyzer i run any update command for any single record (update MAILER.DBO.MAIL_SENT set read_alert='0'where Sent_id='248248')
3. the query will wait for 5 min and 40 sec. to complete
5. while its waiting i checked the locks using the current activity : locks/process ID
6.its giving one process 69 blocking blocking command is SELECT * FROM MAIL_SENT (lock type is TAB mode S)
7. one process 55 blocked by 69 command is update MAILER.DBO.MAIL_SENT set read_alert='0'where Sent_id='248248' lock type TAB mode IX

note the table mail_sent has no of records = 245763 if i runt the query select * from QA it takes 40 sec to complete but not than 5 mins and more

thanks

Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2012-02-23 : 01:22:10
Check your isolation level..

Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-23 : 09:02:53
are you in MAILER DB or are there two different databases involved?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-02-23 : 09:24:23
If you use SSMS to open (Edit Top 200 Rows), you will be locking the rows in the Table view.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-23 : 10:22:08
and so..if you did sp_who2, you would see yourself, blocking..ummm..yourself



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -