Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7944747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:38:45+00:00 2026-06-04T00:38:45+00:00

I am working with SQL 2000. I have gotten to a point where I

  • 0

I am working with SQL 2000. I have gotten to a point where I can remove all of the unwanted duplicates based on a complicated set of criteria, but the query now takes hours to complete when it only used to take about 3.5 minutes to get the data with the duplicates included.

For Clarity:
I can have a duplicate rpt.Name field as long as either the rpt.HostName or rpt.SystemSerialNumber fields is also different. Also, I have to determine which entry to keep based on the time stamps of four different columns as some of those columns have missing time stamps.

Any help is greatly appreciated!

SELECT 
rpt.[Name],
rpt.LastAgentExecution,
rpt.GroupName,
rpt.PackageName,
rpt.PackageVersion,
rpt.ProcedureName,
rpt.HostName,
rpt.SystemSerialNumber,
rpt.JobCreationTime,
rpt.JobActivationTime,
rpt.[Job Completion Time]
FROM DSM_StandardGroupMembersProcedureActivityViewExt rpt
WHERE
(
  (
      rpt.GroupName = 'Adobe Acrobat 7 Deploy'
   OR rpt.GroupName = 'Adobe Acrobat 8 Deploy'
  )
  AND
  (
      (rpt.PackageName = 'Adobe Acrobat 7' AND rpt.PackageVersion = '-1.0')
   OR (rpt.PackageName = 'Adobe Acrobat 8' AND rpt.PackageVersion = '-3.0')
  )
)
AND NOT EXISTS
(
  SELECT *
  FROM   DSM_StandardGroupMembersProcedureActivityViewExt rpt_dupe
  WHERE
  (
    (
     rpt.GroupName = 'Adobe Acrobat 7 Deploy'
      OR rpt.GroupName = 'Adobe Acrobat 8 Deploy'
    )
    AND
    (
     (rpt.PackageName = 'Adobe Acrobat 7' AND rpt.PackageVersion = '-1.0')
      OR (rpt.PackageName = 'Adobe Acrobat 8' AND rpt.PackageVersion = '-3.0')
    )
    AND
    (
      (rpt_dupe.[Name] = rpt.[Name])
      AND
      (
       (rpt_dupe.SystemSerialNumber = rpt.SystemSerialNumber)
    OR (rpt_dupe.HostName = rpt.HostName)
      )
      AND
      (
       (rpt_dupe.LastAgentExecution    < rpt.LastAgentExecution)
    OR (rpt_dupe.JobActivationTime     < rpt.JobActivationTime)
    OR (rpt_dupe.JobCreationTime       < rpt.JobCreationTime)
    OR (rpt_dupe.[Job Completion Time] < rpt.[Job Completion Time])
      )
    )
  )
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:38:46+00:00Added an answer on June 4, 2026 at 12:38 am

    The reason is the not exists clause.

    One suggests is to rewrite this as a left outer join:

     from <big query> left outer join
          <dups query>
          on <all the fields that constitute a match>
     where <dups query>.<some field> is null
    

    I’ve found that not exists and not in often optimize poorly.

    Another suggestion is to change this query to a more direct implementation:

    with t as (
        SELECT rpt.[Name], rpt.LastAgentExecution, rpt.GroupName, rpt.PackageName,
               rpt.PackageVersion, rpt.ProcedureName, rpt.HostName, rpt.SystemSerialNumber, 
                rpt.JobCreationTime, rpt.JobActivationTime, rpt.[Job Completion Time]
        FROM DSM_StandardGroupMembersProcedureActivityViewExt rpt
        WHERE rpt.GroupName in ('Adobe Acrobat 7 Deploy', 'Adobe Acrobat 8 Deploy') AND
              ((rpt.PackageName = 'Adobe Acrobat 7' AND rpt.PackageVersion = '-1.0') OR
               (rpt.PackageName = 'Adobe Acrobat 8' AND rpt.PackageVersion = '-3.0')
              )
     )
     select t.*
     from t join
          (select name, ..., max(id)
           from t
           group by name, ...
          ) tsum
          on t.id = tsum.id
    

    That is, summarize the table by the columns that you want distinct. Choose one of the rows. Here, I assume there is an “id” field to uniquely identify each row. You might have to use a combination of fields, such as name and date. Without an id, this is more challenging. In more recent versions of SQL server, you can use row_number().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I'm working in SQL Server 2000 (although prayers have been made
we have WinForms app which stores data in SQL Server (2000, we are working
Working with SSRS and a SQL 2000 source, I have a stored procedure that
I am working in development under SQL 2008, however I have a SQL 2000
I am working with T-SQL in SQL Server 2000 and I have a table
Working environment is SQL Server 2000. I have a table with no indexes, no
We have an Excel 2002/XP based application that interacts with SQL 2000/5 to process
I'm working with an old SQL 2000 database and I don't have a whole
I am working with SQL Server 2000, and trying to change the data type
I'm working with a client who has just upgraded from SQL 2000 to SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.