TOP 1 or COUNT ?

Results 1 to 2 of 2

Thread: TOP 1 or COUNT ?

  1. #1
    Join Date
    Dec 1969

    Default TOP 1 or COUNT ?

    to check if there&#039s some data in a table for a particular request, in SQL Server 7,<BR><BR>is it faster to do :<BR>SELECT COUNT(ID)...<BR>and to check if count("id")&#060;&#062;0<BR><BR>or to do :<BR>SELECT TOP 1 ID ...<BR>and to check if not result.eof<BR><BR>?<BR>i think it&#039s TOP 1 but...<BR><BR>thanx

  2. #2
    SPG Guest

    Default RE: TOP 1 or COUNT ?

    If it&#039s not a qualified search (select top 1 id from table;) then it would be faster to do the latter because you&#039re not digging into the recordset at all; you&#039re just grazing the .eof property. On the DB side it shouldn&#039t matter, but in the ASP, I believe the ?.eof is faster.

Posting Permissions

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