Saturday, February 25, 2012

OPENXML WHERE vs JOIN

i'm no sql expert by any means... can somebody please explain to me
which query is better and why
thanks
Query 1
--
SELECT top(1)
@.associationUid = SCUConversationPriority.AssociationUID,
@.retryCount = SCUConversationPriority.RetryCount
FROM SCUConversationPriority,
(SELECT [Name] FROM OPENXML (@.iDoc,'/Allowed/Route') WITH ([Name]
varchar(32))) [Route]
WHERE SCUConversationPriority.Status = @.getStatus AND
SCUConversationPriority.RouteName = [Route].[Name]
ORDER BY
Priority desc,
StatusTimeStamp;
Query 2
--
SELECT top(1)
@.associationUid = SCUConversationPriority.AssociationUID,
@.retryCount = SCUConversationPriority.RetryCount
FROM SCUConversationPriority JOIN
(SELECT [Name] FROM OPENXML (@.iDoc,'/Allowed/Route') WITH ([Name]
varchar(32))) [Route]
ON SCUConversationPriority.RouteName = [Route].[Name]
WHERE SCUConversationPriority.Status = @.getStatus
ORDER BY
Priority desc,
StatusTimeStamp;
The value of the xml document is
DECLARE @.allowed as xml
SET @.allowed = N'<Allowed><Route Name="OINK_SCP_CT"/><Route
Name="OINK_SCP_CR"/></Allowed>'
Where idoc is
EXEC @.err = sp_xml_preparedocument @.idoc OUTPUT, @.allowed
Thanks in advanceCheck the execution plans. They will probably be the same, as your question
is essentially whether
to do joins using the more modern join syntax or the old style (which are th
e same, semantically -
for inner joins).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<bvbone69@.yahoo.com> wrote in message news:1147179841.865433.143510@.e56g2000cwe.googlegroup
s.com...
> i'm no sql expert by any means... can somebody please explain to me
> which query is better and why
> thanks
> Query 1
> --
> SELECT top(1)
> @.associationUid = SCUConversationPriority.AssociationUID,
> @.retryCount = SCUConversationPriority.RetryCount
> FROM SCUConversationPriority,
> (SELECT [Name] FROM OPENXML (@.iDoc,'/Allowed/Route') WITH ([Name]
> varchar(32))) [Route]
> WHERE SCUConversationPriority.Status = @.getStatus AND
> SCUConversationPriority.RouteName = [Route].[Name]
> ORDER BY
> Priority desc,
> StatusTimeStamp;
> Query 2
> --
> SELECT top(1)
> @.associationUid = SCUConversationPriority.AssociationUID,
> @.retryCount = SCUConversationPriority.RetryCount
> FROM SCUConversationPriority JOIN
> (SELECT [Name] FROM OPENXML (@.iDoc,'/Allowed/Route') WITH ([Name]
> varchar(32))) [Route]
> ON SCUConversationPriority.RouteName = [Route].[Name]
> WHERE SCUConversationPriority.Status = @.getStatus
> ORDER BY
> Priority desc,
> StatusTimeStamp;
> The value of the xml document is
> DECLARE @.allowed as xml
> SET @.allowed = N'<Allowed><Route Name="OINK_SCP_CT"/><Route
> Name="OINK_SCP_CR"/></Allowed>'
> Where idoc is
> EXEC @.err = sp_xml_preparedocument @.idoc OUTPUT, @.allowed
> Thanks in advance
>

No comments:

Post a Comment