Lock 'Childreen' Table

Hi!

I'mnew in SQL and Ive beenthe problem bellow:

I lock a record in oneforeign table and automaticaly SQL lock the record that matches on primary table.

But this occours just in some primaries tables and not in all. I need that just the table that areof SELECT are lock. How can I do this?

Example:

** At open of the invoice:

SET ISOLATION LEVEL READ UNCOMMITTED

BEGIN TRANSACTION

SELECT * FROMINVOICE WITH (ROWLOCK UPLOCK) WHERE ( ID =15 )

******* at the end of invoice:

INSERT INTO INVOICE ........

COMMIT TRANSACTION

END

******* The relationship are:

INVOICE<>>ITENS_INVOICE

ITENS_INVOICE <>> PRODUCTS

CUSTOMER <>> INVOICE

VENDORS<>> INVOICE

Just the INVOICE and PRODUCTS records involved in Transaction are lock. ( The CUSTOMER and VENDORS are not locked for example )

But I need that just INVOICE record be locked.

Thanks for alland sorry my English.

Igor Sane

So Paulo - Brazil

October 26th, 2006 4:23pm

PS: This doesnt occours in SQL Express, just in SQL Server 2005....

Free Windows Admin Tool Kit Click here and download it now
October 26th, 2006 4:29pm

Isane,

Is this still an issue? Thank you!

March 24th, 2014 1:53am

You can not lock SELECTs

If you use 

CREATE TABLE t1 (c int)
BEGIN TRAN
SELECT  top 0 * FROM t1 WITH (TABLOCK, REPEATABLEREAD) 

INSERT INTO t1 ....

In another Window users will be blocked to insert a new row into a t1 table

Free Windows Admin Tool Kit Click here and download it now
March 24th, 2014 2:05am

You can not lock SELECTs

If you use 

CREATE TABLE t1 (c int)
BEGIN TRAN
SELECT  top 0 * FROM t1 WITH (TABLOCK, REPEATABLEREAD) 

INSERT INTO t1 ....

In another Window users will be blocked to insert a new row into a t1 table

March 24th, 2014 2:31am

>>>Uri, did you want to become a Moderator in this forum? 

Yes, no problem.

Free Windows Admin Tool Kit Click here and download it now
March 24th, 2014 3:44am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics