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 2005 Forums
 Transact-SQL (2005)
 Locking some tables in a stored procedure

Author  Topic 

Mehdi
Yak Posting Veteran

64 Posts

Posted - 2009-01-19 : 03:04:08
Hi,
I have sp which calculating huge amount of data so it take lots of time during the execution i need to lock some tables, even no select query should be run on those tables
which command should i use?
tanks.

_____________
Mehdi.
software student.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-19 : 03:20:26
use xlock & paglock
Go to Top of Page

Mehdi
Yak Posting Veteran

64 Posts

Posted - 2009-01-19 : 04:05:27
quote:
Originally posted by visakh16

use xlock & paglock


how to use them in a strode procedure on different tables

I am runing
create proc CalculationProcess
as
//i need to lock tbl1 here
//i need to lock tbl2 here
//doing some process on tbl3
select * from tbl3 where....
//i need to unlock tbl1 and tbl2 here

_____________
Mehdi.
software student.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2009-01-19 : 04:26:57
Why do you want to lock table1 and table2 when you're doing processing on table3? How are they related?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

Mehdi
Yak Posting Veteran

64 Posts

Posted - 2009-01-19 : 04:41:03
quote:
Originally posted by GilaMonster

Why do you want to lock table1 and table2 when you're doing processing on table3? How are they related?

--
Gail Shaw
SQL Server MVP


well this is for a stock managing puprose,tbl3 has some info about the goods and the number of them tbl2 and tbl1 has info on assingnments and bills of the importing and exporting goods to stockrooms while i am claculating the amount of imported and exported for determinig the probable frauds of a good on tbl3 the user should not get info from tbl1 and tbl2 or update them.
Go to Top of Page
   

- Advertisement -