Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incorrect syntax near the keyword 'ORDER'

Status
Not open for further replies.

multiplex77

Programmer
Dec 25, 2001
302
SG
Hi,

I seem to be getting a SQL Server error (see below) on my ASP pages, but the funny thing is when I run that exact same SELECT query in Query Analyzer, it runs fine. (I did a "Response.Write strQuery" to be sure.) How could this be?

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'ORDER'.


Thanks for the help.
 
This is my query:

SELECT data.ID, data.Name, data.Department FROM data ORDER BY Name

I've checked that all the 3 selected fields exist in the table "Data". In any case, this query runs fine in Query analyzer. once I remove the "Order by" clause, it runs fine in ASP too.

Thanks.
 
I havent got a clue whats wrong but the sql statement is fine, i just tested it against one of my access databases and theres no problem. Perhaps the error is to do with sql server.

Sorry! Nick (Web Developer)


nick@retrographics.co.uk
 
Double check that the word data is not a reserced word for access, I am pretty sure the word ID is. Generally this type of error only crops up when a table or field is named something that is a reserved word. Than it will only run when you paste it into Access, not from outside access.
-Tarwn ------------ My Little Dictionary ---------
Extreme Programming - (1)Trying to code before my second cup of coffee. (2) While(1){ Ctrl+C; Ctrl+V; }
FAQ - Web-ese for "Forget Asking Questions, I am to busy" :p
 
just try this

SELECT data.ID, data.Name, data.Department FROM data ORDER BY [Name]


prasad

sawantprasad2001@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top