Which on is the Best option???

  • Dear Friend,

    i need your help...

    which one SQL query gives me the Faster Output from below...

    1). select Auditdata.* from auditdata auditdata

    inner join Circlemaster c_mst on

    auditdata.circlemaster_id<>C_mst.circlmaster_id

    where tatcalltype is null

    or

    2). select Auditdata.* from auditdata auditdata

    inner join Circlemaster c_mst on

    auditdata.circlemaster_id not like C_mst.circlmaster_id

    where tatcalltype is null

  • Why don't you try them both and see?

    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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Since you don't have any wildcards defined in the one using NOT LIKE, I would think that the optimzer would evaluate them the same, but as Gail said, "Try it and see".

  • My concerns regard both is the possibility of extraneous data returned based on the joins.

  • I've run into instances where and NOT LIKE are not necessarily the same (actually, = and LIKE). Here is an example, possibly more obscure than any real data. But, the point is that some Unicode characters seem to be treated as whitespace:DECLARE @S1 NVARCHAR(10)

    DECLARE @S2 NVARCHAR(10)

    SET @S1 = N'wedding ' + NCHAR(8238)

    SET @S2 = N'wedding'

    SELECT

    CASE

    WHEN @S1 = @S2

    THEN 1

    ELSE 0

    END,

    CASE

    WHEN @S1 COLLATE SQL_Latin1_General_CP1_CI_AS = @S2 COLLATE SQL_Latin1_General_CP1_CI_AS

    THEN 1

    ELSE 0

    END,

    CASE

    WHEN CAST(@S1 AS VARBINARY) = CAST(@S2 AS VARBINARY)

    THEN 1

    ELSE 0

    END,

    CASE

    WHEN @S1 LIKE @S2

    THEN 1

    ELSE 0

    END

  • Lynn Pettis (7/24/2009)


    My concerns regard both is the possibility of extraneous data returned based on the joins.

    Yeah. That's one very strange join condition.

    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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply