Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Distributed Transaction Expand / Collapse
Author
Message
Posted Sunday, August 10, 2008 6:54 PM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, September 9, 2012 9:12 PM
Points: 8, Visits: 37
Good Day,

I'm new to Distributed Transaction, and i'm getting this error

Server: Msg 7377, Level 16, State 1, Line 5
Cannot specify an index or locking hint for a remote data source.

I need to have the locking hint within my query, but i have to connect onto another server so I have to use the distributed transaction for me to be able to create a transactional query.

This is my situation:

my PC is in 192.168.1.101 and the server in on 192.168.1.100
I am testing this query:

BEGIN TRANSACTION

DECLARE @ID AS BIGINT

SELECT TOP 1
@ID = [ID]
FROM [192.168.1.100].SERVER_DB.DBO.TEST_TABLE
WITH(UPDLOCK)
WHERE
ROWLOCKED = 0 AND
ISPROCESSED = 0

COMMIT TRANSACTION

now im stuck : (

Please I need your expertise on this.

Thanks!


_____________________________________________
ToM™ (Possibility will come out of nothing)
Post #549957
Posted Sunday, August 10, 2008 10:31 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 9:34 AM
Points: 35,532, Visits: 32,115
You cannot use locking hints that way... period. ;)

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #549992
Posted Monday, August 11, 2008 1:21 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 2:01 PM
Points: 40,390, Visits: 36,823
As Jeff said, not possible.

I'm curious. Why would you want to do a select with an UPD lock and then immediately commit the transaction? You're not achieving anything as the lock will be dropped as soon as the transaction commits.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #550051
Posted Tuesday, August 12, 2008 6:43 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, March 6, 2014 6:13 PM
Points: 318, Visits: 1,183
Create a stored proc on the remote server that encapsulates your logic, and execute it from the local server. You should be able to use your locking hints in it with no problems.

It's generally best to use procs across a remote server boundary in many cases - avoids the chance that the local server will try to drag any of the remote tables across to resolve your criteria. Not appropriate for all cases, but I find that the majority perform better using procs.

Regards,

Jacob
Post #551518
Posted Tuesday, September 2, 2008 2:49 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, September 9, 2012 9:12 PM
Points: 8, Visits: 37
Thanks guys! My situation is this; I have source table from a server which is my Inbox.tbl and I have multiple instance of application that continuously reading this table ex:

DECLARE
@MESSAGE AS VARCHAR(200) ,
@INBOXID AS BIGINT

SELECT
@INBOXID = INBOXID ,
@MESSAGE = MESSAGE
FROM INBOX
WITH(UPLOCK)
WHERE
ROWLOCKED = 0 AND
ISPROCESSED = 0

IF @INBOX IS NOT NULL /* RETRIEVED RECORD */
BEGIN

/* MARK THE TABLE AS LOCKED */
UPDATE INBOX
SET
ROWLOCKED = 1
WHERE
INBOXID = @INBOXID

At this point, since I have retrieved a record, I have to call a stored procedure located at another database server to process the request based from the catch message “@MESSAGE

But in my query I have to continuously hold the transaction; that’s why im using the distributed transaction.

END




But as of my workaround permits, I put my parsing code onto another server which uses XLOCK and its quite working now.


_____________________________________________
ToM™ (Possibility will come out of nothing)
Post #562254
Posted Tuesday, September 2, 2008 2:52 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, September 9, 2012 9:12 PM
Points: 8, Visits: 37
Actually Gila, I do it because I have multiple instance of application which calls this stored procedure, the duty of this SP is to get new request from my inbox table, but without duplication of transaction, because some of this request has account transaction.

_____________________________________________
ToM™ (Possibility will come out of nothing)
Post #562255
Posted Thursday, September 4, 2008 6:33 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, October 10, 2013 4:59 PM
Points: 79, Visits: 183
Try adding the keyword "DISTRIBUTED" to your begin transaction statement.

IE:

BEGIN DISTRIBUTED TRANSACTION
...


This will change the way the transaction locks data. I'm pretty sure I had that working with SQL 2000. It does take the correct server setup to get working though.


Gary Johnson
Sr Database Engineer
Post #564274
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse