473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

UPDLOCK on a mult-table join

Hi all,

Is this legal ?

SELECT a.col1,b.col2,c.col3
FROM tab1 a WITH (UPDLOCK) , tab2 b, tab3 c
WHERE a.col1 = b.col1
and b.col2 = c.col1

WIll the above cause a UPDLOCK on tab1 and not tab2 and tab3?

COmments,thoughts,criticisms?

I have a problem with a query that performs a multi-table join
to get column values and then one of the tables in the join is
being updated. I am getting DEADLOCKs and was wondering if I could
try and reduce that.

Also how can I find out what locks are in effect for a certain
query..Is it syslocks or are there any other tables..?

DrD

Jul 23 '05 #1
2 3561
drdeadpan (vk***********@yahoo.com) writes:
Is this legal ?

SELECT a.col1,b.col2,c.col3
FROM tab1 a WITH (UPDLOCK) , tab2 b, tab3 c
WHERE a.col1 = b.col1
and b.col2 = c.col1

WIll the above cause a UPDLOCK on tab1 and not tab2 and tab3?
Yes. A table hint always affects one table only. You can use the
OPTION clause for hints that affects the entire SELECT statement.
However, you cannot specify locking hints in OPTION.
Also how can I find out what locks are in effect for a certain
query..Is it syslocks or are there any other tables..?


master.dbo.syslockinfo is the table to look in. Or use sp_lock.

Or for a more versatile of information, you use my aba_lockinfo,
available at http://www.sommarskog.se/sqlutil/aba_lockinfo.html.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2
WIll look into it. Thanks

DrD

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bart Nessux | last post by:
In Python, I can do something like this: a,b,c = 1,2,3 How might I do this with PHP? Thanks, Bart
2
by: D Barry | last post by:
Greetings: I am trying to conceive what risks might be created by running multiple SQL servers within a domain under a single domain account, as opposed to 1) running under the local service...
5
by: Rose | last post by:
I want to use the javascript dom to reference the field of a record in a multi-record html form when that field has been changed. How do I reference the field? I have a JavaScript function coded...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
3
by: Jerry Hewett | last post by:
Is there anything I can do from the Enterprise Manager console or from within a JDBC connection to achieve the same effect as WITH(UPDLOCK)? Yes, I could change all of my SQL statements to...
44
by: gokkog | last post by:
Hi there, There's a classic hash function to hash strings, where MULT is defined as "31": //from programming pearls unsigned int hash(char *ptr) { unsigned int h = 0; unsigned char *p =...
3
by: GaryDean | last post by:
I have serveral applications now running that are using the MembershipProvider classes and they are each using their own security tables in SQL Server 2005 instead of the express databases - they...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.