SQL server - indexing

Results 1 to 2 of 2

Thread: SQL server - indexing

  1. #1
    Join Date
    Dec 1969

    Default SQL server - indexing

    Hello all,<BR> I have a table with 2 million records. I have field names name,number,begindate,enddate,timeofoccurence. I have to write a query to get the duplicate values. My query is<BR><BR>Select name,number,begindate,enddate,timeofoccurence <BR>from table1<BR>group by name,begindate,enddate,timeofoccurence <BR>having count(number)&#062;1<BR>order by name.<BR><BR>the query timed out. I did a clustered index on name and number. I ran it on query analyzer. It took 4:45. Can any one suggest me what would I have to do to overcome this problem.<BR><BR>thank you<BR>Rajesh <BR><BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL server - indexing

    Just out of curiosity in Query Analyzer, is the following any faster for you?<BR><BR>SELECT name, begindate, enddate, timeofoccurence, count(name) <BR>FROM table1 <BR>GROUP BY name,begindate,enddate,timeofoccurence <BR>HAVING count(name)&#062;1 <BR>ORDER BY name<BR><BR>Obviously you could also experiment with adding indexes to begindate, enddate, and/or timeofoccurence.<BR><BR>Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts