Is it maybe just a comment? -- what is the next line
If its' something like
SELECT * FROM abc WITH (HOLDLOCK)
then just add the comment "--" before the line you displayed
Main Topics
Browse All TopicsI have the following I copied from some where:
BEGIN TRANSACTION
lock table ABC in exclusive mode
.... ....
COMMIT TRANSACTION
But it is not working. It keps saying:
Incorrect syntax near 'ABC'.
What's wrong here?
Thanks for any help.
Jennifer
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
But I still want to ask.
I have teo transactions, will
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
affect both?
My code looks like:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION
....
END TRANSACTION
BEGIN TRANSACTION
....
END TRANSACTION
Will "SET TRANSACTION" affect both transactions or just the first one?
Thanks,
Jennifer
Jennifer, I'm not sure that's what you want to do. Yes, it will affect both transactions. Actually, it'll affect all transactions issued by that connection. The problem is, you'll lock every table involved with every select statement in the transaction. If you're updating or inserting and trying to lock the table from reads during those operations, SET TRANSACTION ISLATION LEVEL won't even help at all. If all you want to do is ensure that you're not getting a dirty read, then you only nead SET TRANSACTION ISOLATION LEVEL READ COMMITTED.
Either way, you're better off specifying the minimum required lock on a per table basis.
Just a thought,
TNC
Thanks a lot for your help.
What I want to do is that I want to lock the first transaction only.
In my first transaction, I have a select and then an insert to the same table. I don't want anyone to touch this table within the first transaction. And I don't want to apply any lock on the 2nd transaction.
How should I do that?
Thanks again,
Jennifer
Business Accounts
Answer for Membership
by: tncbbthositgPosted on 2006-08-21 at 11:38:41ID: 17358091
try WITH TABLOCK in your from clause.
i.e., SELECT * FROM myTable WITH TABLOCK.
TNC