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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Why Transations are Locking the Tables??

Author  Topic 

kaff
Starting Member

11 Posts

Posted - 2006-01-19 : 20:43:47
Hi,

I am using SQL Server 2000 Server. I had one Stored procedure, which basically useing Begin Transation and End Transaction.
The Whole Execution process takes 1 hr to complete, INCLUDES INSERTS AND UPDATE AND DELETE.

Problem is during the whole period of execution, none of my application feature works, as they are reporting tables are locked.

Why? is that DUE to Begin transaction statements?

If I take out the Transaction thingy, then it goes fine, but I don't want to loose the feature of roll back the whole transaction in case of any bug.

Is it a bUG? or I am using it Wrong?

Thanks in Advance




Kaff

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-20 : 02:05:44
If you use Begin Transaction then all the objects that are in that block get locked until the transaction is Committed or rollbacked. There is nothing wrong that other part of application doesnt work. This is helpful if your application is used by multi users

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-20 : 02:12:28
>> The Whole Execution process takes 1 hr to complete
Maybe you should consider optimizing the stored procedure and also spliting the begin trans .. end trans into smaller block.

By any chance you are using cursor in this SP ?

-----------------
'KH'

Go to Top of Page

kaff
Starting Member

11 Posts

Posted - 2006-01-22 : 14:13:53
Thanks all for feedback
Yes.. I am using cursors a lot. Infact in every stored procedure..
is that causing the issue as well?

Thanks again




Kaff
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-23 : 02:43:41
>>Yes.. I am using cursors a lot. Infact in every stored procedure..

Cursors perform slowly. It is better to use Set based approach

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -