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.
Roy Harvey
Beacon Falls, CT
On 3 May 2006 12:45:58 -0700,
rs*@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?