I am definitely not the best person to comment on the internal locking =
mechanisms of MSSQL... Have a read of Books Online, the "Accessing and =
Changing Data" chapter will probably be useful for you.
Joins are an integral part of SQL, and I don't think that avoiding them =
will provide many (or any) benefits.
Just my opinion...
Regards,
Damien.
[quoted text, click to view] "John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message =
news:eYv#J357DHA.1112@tk2msftngp13.phx.gbl...
hi Damien and thanks for the response.
very interesting stuff. so, extrapolating from this example, unless a =
sp
locks the tables it's working with, or wraps its code in an explicit
transaction, there is no way to stop the sql-svr engine from =
multitasking
execution of t-sql lines in SPs run under different connections ... ?
"Damien Laffan" <iGetEnoughSpamAlreadyThankyou@nospam.com> wrote in =
message
news:Oksy4r57DHA.3112@tk2msftngp13.phx.gbl...
You may wish to consider that there is no guarantee that the row in =
table1
is not deleted between query 1 and 2... (Unless you wrap the whole lot
inside an explicit transaction, I believe)
By joining you get all the data that matches your criteria at the point =
in
time the query is executed, without the hassle of transient variables =
etc...
Regards,
Damien.
[quoted text, click to view] "John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:#wFvob57DHA.1636@TK2MSFTNGP12.phx.gbl...
i'm sure the following has been extensively benchmarked ...
a stored procedure to retrieve a single row .... @PrimaryKeyFieldValue =
is sp
input parameter
method 1 :
select @ForeignKeyFieldValue from Table1 where T1.PrimaryKeyFieldName =
=3D
@PrimaryKeyFieldValue
select * from Table2 where PrimaryKeyFieldName =3D @ForeignKeyFieldValue
method 2 :
select * from Table2 T2 inner join Table1 T1 where =
T2.PrimaryKeyFieldName =3D
T1.ForeignKeyFieldName and T1.PrimaryKeyFieldName =3D =
@PrimaryKeyFieldValue