Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Why doesn't TOP work in SS2000?

Author  Topic 

nzmike
Starting Member

21 Posts

Posted - 2003-08-10 : 06:04:51
Hi,

My first post here and it should be an easy one... no matter what I try I can't get the TOP function to work in SQL Server 2000.

If I do this:
SELECT TOP 10 * FROM ORDERS
then SQL Server tells me this:
Line 1: Incorrect syntax near '10'.

I also tried doing TOP(10) and that told me: 'TOP' is not a recognized function name.

I am really confused - Books Online refers (in it's completely useless way) to the TOP function and I have seen other posts on this forum where it appear to be used, but my copy of SS2000 just won't let me do it! What am I doing wrong here?!?!

TIA for any help...

Mike.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-08-10 : 08:32:56
quote:
Books Online refers (in it's completely useless way) to the TOP function and I have seen other posts on this forum where it appear to be used, but my copy of SS2000 just won't let me do it! What am I doing wrong here?!?!
Assuming Books Online is useless and not reading it thoroughly.

Check the compatibility level of your database. It is most likely set to 6.5 (did you upgrade from SQL 6.5?) TOP was not supported until SQL 7.0.
Go to Top of Page

nzmike
Starting Member

21 Posts

Posted - 2003-08-10 : 18:53:45
I've never had 6.5 on my PC at all so I eliminated that straight off... then realised the copy of the DB I am using is from my client site who used v7 until recently (and 6.5 before that most likely) so I looked in the Books Online again (OK, it's not that bad but I still find it very wanting in many areas - only my opinion) and found the sp_dbcmptlevel procedure.
So I ran this: EXEC sp_dbcmptlevel 'XMLOrdering', 70
then tried the SELECT TOP 3 FROM... query again and got the required results.

Thanks for the help... you can tell I'm no DBA!

Mike.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-08-10 : 19:52:15
You will also need to test the system to make sure it doesn't rely on anything that changed in v7.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -