If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > SQL _Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-10, 22:12
cnr4u cnr4u is offline
Registered User
 
Join Date: Jan 2010
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 01-13-10, 13:12
PMASchmed PMASchmed is offline
Registered User
 
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 .
Reply With Quote
  #3 (permalink)  
Old 01-14-10, 06:51
cnr4u cnr4u is offline
Registered User
 
Join Date: Jan 2010
Posts: 2
Smile

HI PMASchmed Thank You for you replay.

cnr4u
Reply With Quote
Reply

Tags
2008, sql, sql query

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On