Groups | Blog | Home
all groups > sql server clients > march 2007 >

sql server clients : Text column in select query


Rogers
3/26/2007 12:47:56 PM
I have a text column table and that contains 3000 records but when I try to
use top 10 query and include text column it take 10 minutes and when I
remove the text column from the select query it takes a second, any idea how
we can speed up the query if I include text column in my list.

Russell Fields
3/26/2007 2:49:26 PM
Rogers,

You don't mention what you are ordering by (and perhaps also grouping by),
but assuming that the text column is not included in the ORDER BY or GROUP
BY clauses:

SELECT TOP 10 ID, colA, colB, colC
INTO #temp
FROM MyTable
ORDER BY colC, colB, colA

SELECT t.colA, t.colB, t.colC, m.textcolumn
FROM #temp t JOIN MyTable m
ON t.ID = m.ID
ORDER BY colC, colB, colA

This simply gets the text column out of the TOP 10, but returns it from the
second select.

RLF
[quoted text, click to view]

AddThis Social Bookmark Button