title: SQL Server Search, how to return the total count of rows?
body: <p>I have another <a href="https://stackoverflow.com/questions/1779012/search-function-sql-server">post</a> which resulted in this </p>
  
  <pre><code>SELECT DISTINCT
          a.ArticleID, 
          COUNT(*) AS KeywordMatch,
          a.Headline,
          a.ShortDescription,
          a.CategoryID,
          a.ArticleSectionImage,
          a.DatePublished
      FROM 
          Article a
      JOIN SearchWords sw ON a.ArticleID = sw.ArticleID
      WHERE
          EXISTS 
          (
              SELECT 
                1 
              FROM 
                iter_charlist_to_tbl(@temp, ' ') s 
              WHERE
                s.nstr = sw.SearchWord
          )
          AND
              a.ArticleState = 3  
      GROUP BY 
          a.ArticleID, a.Headline, a.ShortDescription, a.CategoryID, a.ArticleSectionImage, a.DatePublished
      ORDER BY (KeywordMatch) DESC, (a.DatePublished) DESC
  </code></pre>
  
  <p>I am using this along with Linq-to-SQL to create paging for the users. The problem is, that i need to know how many records my search returned (total rows), to display the correct arrows for the user.</p>
  
  <p>This is my Linq-to-SQL Query:</p>
  
  <pre><code>  int iPageNum = pageNumber;
    int iPageSize = (int)pageSize;
  
    results = data.SearchArticles(searchString).Skip((iPageNum - 1) * iPageSize).Take(iPageSize).ToList(); 
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p><strong>Is my Linq-to-SQL pulling all records from the database? or does it create a query that only selects the records that i needs?
  How can i peak at the query?</strong></p>