August 10, 2008 at 6:54 pm
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!
_____________________________________________
[font="Verdana"]ToM™[/font] (Possibility will come out of nothing)
August 10, 2008 at 10:31 pm
You cannot use locking hints that way... period. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
August 11, 2008 at 1:21 am
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, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 12, 2008 at 6:43 pm
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
September 2, 2008 at 2:49 am
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) ,
@INBOXIDAS 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.
_____________________________________________
[font="Verdana"]ToM™[/font] (Possibility will come out of nothing)
September 2, 2008 at 2:52 am
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.
_____________________________________________
[font="Verdana"]ToM™[/font] (Possibility will come out of nothing)
September 4, 2008 at 6:33 pm
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
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply