Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    57

    Unanswered: getting only the first occurance of a sql select statement

    I am making a sql query and its bring back hundreds of results but I only need the first one. I am aware that getting the first one will be faster as well. Is there an efficient way to do this?

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Assuming you are using SQL 2000 or earlier:
    Code:
    SELECT TOP 1 *
       FROM dbo.sysobjects
    -PatP

  3. #3
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by Pat Phelan
    Assuming you are using SQL 2000 or earlier:
    Code:
    SELECT TOP 1 *
       FROM dbo.sysobjects
    -PatP
    Don't forget an ORDER BY clause or your results may be unpredictable.

    Regards,

    hmscott
    Have you hugged your backup today?

Posting Permissions

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