Results 1 to 3 of 3

Thread: SQL _Query

  1. #1
    Join Date
    Jan 2010
    Posts
    2

    Unanswered: SQL _Query

    SELECT COUNT(DISTINCT(Email))
    FROM( SELECT Email1,Email2,Email3, Email4,Email5,Email6,Email7,Email8,Email9,Email10 FROM outputresume3
    WHERE ((contains (originalresume, '"j2ee" and "java"'))
    AND (currentdateout BETWEEN '2000-01-01' AND '2010-01-06'))
    )p
    UNPIVOT (Email FOR Emails IN (Email1,Email2,Email3,Email4,Email5,Email6,Email7, Email8,Email9,Email10)) as unpvt
    WHERE LEN(Email) > 0



    The above query returns a large number of results, which occasionally causes a timeout in SQL Server 2008.
    Can you Please rewrite the query to be faster and how would you accurately limit the record count ?

    Regards
    cnr

  2. #2
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Yes, limit your date range, by putting in a loop and inserting results into a table. Make sure correct indexes exist, specifically on currentdateout .

  3. #3
    Join Date
    Jan 2010
    Posts
    2

    Smile

    HI PMASchmed Thank You for you replay.

    cnr4u

Tags for this Thread

Posting Permissions

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