If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > How to return only the first row....

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-03, 12:52
feign3 feign3 is offline
Registered User
 
Join Date: Jan 2003
Posts: 19
Red face How to return only the first row....

Is there a way to return only the first row of a multi-row query. In other words... I have a query returning multiple rows but I want it to stop after it retrieves the first row.

Thanks
Reply With Quote
  #2 (permalink)  
Old 01-16-03, 13:14
rajXesh rajXesh is offline
Registered User
 
Join Date: Jul 2002
Posts: 29
In Oracle you would add

AND ROWNUM = 1

to the WHERE clause

-- rajXesh
__________________
All you need in this life is ignorance and confidence, and then success is sure.
-- Mark Twain (1835 - 1910)
Reply With Quote
  #3 (permalink)  
Old 01-16-03, 14:27
feign3 feign3 is offline
Registered User
 
Join Date: Jan 2003
Posts: 19
Thanks rajXesh!
Reply With Quote
  #4 (permalink)  
Old 01-17-03, 09:48
acg_ray acg_ray is offline
Registered User
 
Join Date: Jan 2003
Location: Pittsburgh, PA
Posts: 86
Question

Is there a similar command for SQL Server?
Reply With Quote
  #5 (permalink)  
Old 01-17-03, 10:15
Joel Joel is offline
Registered User
 
Join Date: Jan 2003
Location: Baltimore; Washington DC
Posts: 1
Quote:
Originally posted by acg_ray
Is there a similar command for SQL Server?
SELECT TOP 1 * FROM [table]
Reply With Quote
  #6 (permalink)  
Old 01-20-03, 15:10
acg_ray acg_ray is offline
Registered User
 
Join Date: Jan 2003
Location: Pittsburgh, PA
Posts: 86
Thx

Thx Joel. That did it.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On