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'))
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 ?