| Author |
Topic |
|
Priya Rajagopalan
Starting Member
10 Posts |
Posted - 2005-09-22 : 23:56:11
|
| "Select top 1 * from <tablename>" query is working fine in one database. If execute the same query in another database in the same server, am getting the error " Incorrect Syntax near 1" .Please let me know a solution for this.Priya |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-23 : 00:20:25
|
| The syntax looks correctIf it works in one database it should definitely work in other databaseMake sure you used the same query in other database alsoMadhivananFailing to plan is Planning to fail |
 |
|
|
Priya Rajagopalan
Starting Member
10 Posts |
Posted - 2005-09-23 : 01:05:08
|
| I executed the same query withy any change. Both the databases has the table with the same name too.Priya |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-23 : 01:39:58
|
| Did you execute in a Query Analyser?MadhivananFailing to plan is Planning to fail |
 |
|
|
Priya Rajagopalan
Starting Member
10 Posts |
Posted - 2005-09-23 : 01:50:12
|
| Yes, I executed it in a query analyser.Priya |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-09-23 : 05:06:31
|
did you copy and paste or change the database name likeuse <dbname>goselect top 1 * from <tablename>or did you re-type? sometimes the cause is obvious that it becomes negligible --------------------keeping it simple... |
 |
|
|
Priya Rajagopalan
Starting Member
10 Posts |
Posted - 2005-09-23 : 06:06:05
|
| HiTried both the ways. Still facing the same issue. Will there be any issue with the database itself ? |
 |
|
|
Priya Rajagopalan
Starting Member
10 Posts |
Posted - 2005-09-23 : 06:39:25
|
| hiIssue has been resolved by myself by changing the 'Database compatability level'. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-23 : 06:53:36
|
| What is your 'Database compatability level' when you have that problem?MadhivananFailing to plan is Planning to fail |
 |
|
|
supersql
Yak Posting Veteran
99 Posts |
Posted - 2005-09-23 : 10:23:42
|
| PriyaWud u pls let us know, how did u able to resolve. What was the database compatibility level before and to what u changed it. |
 |
|
|
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2005-09-23 : 10:41:05
|
| She has got the answer and doesn't need any further help ;-)...So we need to do some analyzing....As faar as i know TOP will not give any problems with SQL2K and greater!And since she is new to SQL server it should be immediate prevoius version to SQL2K. Hence the "server compatibility level" should be - sql 7.0!------------------------I think, therefore I am - Rene Descartes |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-09-23 : 15:48:34
|
| SELECT TOP 1 is valid in SQL Server 7.0 also, so the compatbility level must have been set at 6.5If it was actually set that way for a reason, they may be having new problems now...CODO ERGO SUM |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-09-25 : 22:41:06
|
thanks for the info guys, something new to learn again for today --------------------keeping it simple... |
 |
|
|
|