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
 Other Forums
 SQL Server 6.5 \ SQL Server 7.0
 Cannot Run SELECT TOP

Author  Topic 

ysut
Starting Member

6 Posts

Posted - 2007-06-12 : 00:21:18
I created my own database. But I CANNOT RUN SELECT TOP 10 * FROM <tablename> in the database.

But, if I try to Northwind database, I successfully run the script. Anyone from you can explain why ?

I am using Ms. SQL Server 7.0

Thank you
YSUT

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-12 : 00:22:03
Do you get any error? What is the error description?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

ysut
Starting Member

6 Posts

Posted - 2007-06-12 : 00:23:49
Error like below :

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '10'.

The syntax is : SELECT TOP 10 * FROM <tablename>

Thanks
YSUT
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2007-06-12 : 02:55:47
You need an Order By otherwise there is nothing to determine the TOP by


steve

-----------

Don't worry head. The computer will do all the thinking from now on.
Go to Top of Page

ysut
Starting Member

6 Posts

Posted - 2007-06-12 : 03:46:00
I Did.

This is the full syntax. But I still got the same error

select TOP 10 * FROM m_teknisi ORDER BY kd_teknisi

All the tables cannot be execute with SELECT TOP syntax in my own database.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-12 : 08:55:28
Check the compatibility mode of your database. I guess it is set to 6.5.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-12 : 09:06:02
quote:
Originally posted by elwoos

You need an Order By otherwise there is nothing to determine the TOP by


steve

-----------

Don't worry head. The computer will do all the thinking from now on.


Order by will make sense when using TOP though not neccessary to use

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-06-12 : 12:18:52
It works on sql2k and later only.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-12 : 12:25:41
I believe TOP operator was introduced in 7.0.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-06-12 : 12:36:09
You are right. Is the db in 70 compatibility level?
Go to Top of Page

ysut
Starting Member

6 Posts

Posted - 2007-06-12 : 19:17:42
I See.
Thank you very much for the replies. I asked the DB administrator, and you're right that the DB is compabtile only with version 6.5, since at the first time, we started with 6.5 version, and upgrade to version 7.0 at 1 year later.

Case closed, and again, thanks a lot

Regards
YSUT
Go to Top of Page
   

- Advertisement -