TOP clause in Select

TOP clause in Select

Post by Mike Coffe » Mon, 23 Jul 2001 02:09:24



One of my databases does not support the TOP clause
whereas another one does (on the same server). What is
different about 1 DB that prevents me from using TOP? It
is a very large (80m rows) DB.
 
 
 

TOP clause in Select

Post by Dan Guzma » Mon, 23 Jul 2001 02:36:19


A likely cause is that the database is set to 65 compatibility level.  This
can be changed with sp_dbcmptlevel.  Details in the Books Online.

Hope this helps.

-----------------------
SQL FAQ links (courtesy  Neil Pike):

 http://forumsb.compuserve.com/gvforums/UK/default.asp?SRV=MSDevApps
 (faqxxx.zip in lib 7)
 or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
 or www.sqlserverfaq.com
 or www.mssqlserver.com/faq
-----------------------


Quote:> One of my databases does not support the TOP clause
> whereas another one does (on the same server). What is
> different about 1 DB that prevents me from using TOP? It
> is a very large (80m rows) DB.


 
 
 

TOP clause in Select

Post by Tom Morea » Mon, 23 Jul 2001 02:37:44


Your compatibility mode for the database is not at 70 or greater.  Use the
sp_dbcmptlevel stored proc to set it.

--
   Tom

----------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCT
SQL Server MVP
Columnist, SQL Server Professional

Toronto, ON Canada
www.pinnaclepublishing.com/sql
www.apress.com
---

One of my databases does not support the TOP clause
whereas another one does (on the same server). What is
different about 1 DB that prevents me from using TOP? It
is a very large (80m rows) DB.

 
 
 

TOP clause in Select

Post by BP Margoli » Mon, 23 Jul 2001 02:45:44


Mike,

Most probable cause is that the database that does not support the TOP
keyword is in either 60 or 65 database compatibility mode. Check out the
documentation in the SQL Server Books Online for the system stored procedure
sp_dbcmptlevel for additional information.

The database must be in either 70 or 80 compatibility mode for the TOP
keyword to be recognized. Note that if this is a production database, then
there are other possible, significant, effects that might occur by changing
the compatibility level, so be sure to test the database and application
thoroughly after changing the compatibility level.

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


Quote:> One of my databases does not support the TOP clause
> whereas another one does (on the same server). What is
> different about 1 DB that prevents me from using TOP? It
> is a very large (80m rows) DB.

 
 
 

TOP clause in Select

Post by Mike Coffe » Mon, 23 Jul 2001 02:58:53


Thats great! Its fixed.

Quote:>-----Original Message-----
>A likely cause is that the database is set to 65

compatibility level.  This
>can be changed with sp_dbcmptlevel.  Details in the Books
Online.

>Hope this helps.

>-----------------------
>SQL FAQ links (courtesy  Neil Pike):

> http://forumsb.compuserve.com/gvforums/UK/default.asp?
SRV=MSDevApps
> (faqxxx.zip in lib 7)
> or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
> or www.sqlserverfaq.com
> or www.mssqlserver.com/faq
>-----------------------



>> One of my databases does not support the TOP clause
>> whereas another one does (on the same server). What is
>> different about 1 DB that prevents me from using TOP? It
>> is a very large (80m rows) DB.

>.

 
 
 

1. top clause in select statement

Greetings:

Does anybody have a working example of how to get the top n records in a
select statement?  Copying and pasting the examples from MSDN doesn't work.

I'm trying to get the following statement to function:

    SELECT TOP 10 * FROM table WHERE condition ORDER BY column ASC

Thanks;
Duncan

P.S. I'm using 6.5

2. newbie struggling with mysql

3. selecting top n from a group by clause?

4. in-doubt distributed transaction

5. Using DELETE and a SELECT with the TOP Clause

6. Select statement in a variable

7. EXTRANGE ERROR IN SELECT TOP N CLAUSE

8. where to find explanations for all SQLSTATE messages?

9. TOP N in select clause causes error for EXPLICIT mode

10. Parameter in 'Select Top' clause

11. TOP 1 without TOP clause USING GROUP BY

12. SELECT TOP @top

13. SQL - way to select the top 10 / top 20 from a database