Search code examples
ms-accessoledb

select top 700 * from objectaer work only in sqlserver 2005 but 2008


how can I select the last 700 entry in my access databse? I'm using this

    private string strsqlcommandBeta = "select top 700 * from objectaer  " +
    " order by objectdate desc" +
    "  ";

but I'm getting this error

The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.


Solution

  • The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.

    Typically this is a result of using a keyword as a field name in one of your tables, or as an alias in your query. If you don't "quote" the keyword-as-a-field-name with [] you'll get an error.

    Although I can't see any keywords being used inappropriately in your query, try this:

    SELECT TOP 700 * FROM [objectaer] ORDER BY [objectdate] DESC
    

    It's also possible that the problem is not with your query, rather if objectaer is a query object you've created in Access that contains incorrect syntax, you're likely seeing the error for objectaer instead.