|  | Posted by Greg D. Moore \(Strider\) on 05/04/06 06:29 
"Roy Harvey" <roy_harvey@snet.net> wrote in messagenews:bj2i5256taa324mt0v5umfdbnvc4p1om58@4ax.com...
 > As you are learning, SQL Server has little in common with Access.  SQL
 > Server stays much closer to the relational model.  In this case, the
 > relational model tells us that tables are un-ordered sets; there is no
 > concept of first or last in sets.
 >
 > The SQL Server 2005 documentation also says that set rowcount will be
 > going away some day.  We should be using TOP instead, in this case TOP
 > 1.  With an ORDER BY, TOP 1 will return the "first" row as determined
 > by the ORDER BY.  Without the ORDER BY the single row returned is
 > random.
 
 Actually row_number() or rank() is an even better solution.
 
 But agreed, rowcount isn't a good solution here.
 
 
 >
 > Roy Harvey
 > Beacon Falls, CT
 >
 > On 3 May 2006 12:45:58 -0700, rss@ddsc.com wrote:
 >
 > >set rowcount 1
 > >select  Idnum1,Idnum3 from mytable order by    Idnum1 DESC, idnum3 ASC
 > >
 > >is equivelent to
 > >select first(Idnum1),first(idnum3)  from mytable order by first(Idnum1)
 > >DESC ,first(Idnum3) ASC
 > >
 > >
 > >Isn't that silly? why did Microsoft not add an agregate function First
 > >for the Microsoft SQL Server to be consistent with its Microsoft Access
 > >product eh?
  Navigation: [Reply to this message] |