I have a very large database where I need to select the First record only matching my criteria, not the entire set. Is there a way to so something like this?
Ex: Select FIRST from database where status = 'notProcessed'
dotme
2:52 pm on Feb 5, 2005 (gmt 0)
I think you need an "ORDER BY" clause. If you know what field to sort by (a date field, for example) you can ORDER BY datefield and then pull only the first record.
mattglet
3:03 pm on Feb 5, 2005 (gmt 0)
Select TOP 1 from database where status = 'notProcessed'
Easy_Coder
3:16 pm on Feb 5, 2005 (gmt 0)
in addition to TOP you also have this option...
set rowcount 1 select FIRST from database where status = 'notProcessed' set rowcount 0
too much information
4:28 pm on Feb 5, 2005 (gmt 0)
Thanks for all of the help!
Turns out to be:
Select TOP 1 * from database where status = 'notProcessed'