0

I'm using VB2010 express with MS SQLServer Express. I'm using a DataAdapter to fill a DataTable (not DataSet).

For some reason I'm getting an error when using 'LIMIT' in my query. Specifically

SELECT * FROM people ORDER BY id LIMIT 1

I've also tried ",limit 1, LIMIT(1), LIMIT (1)" and the all throw an error saying I have a syntax error near "LIMIT" or "1" and with the comma I get LIMIT is not a built in function.

If I omit the LIMIT part, the query runs fine and I get the entire table. What I can find in M$ docs says LIMIT is a valid parameter...

I know LIMIT can't be used without ordering the result but there is an ORDER BY that works in the statement.

Confused arg.

Thanks!

  • 1
    LIMIT is a MySql function. Check out this post to recreate it's behavior in MS SQL http://stackoverflow.com/questions/603724/how-to-implement-limit-with-microsoft-sql-server – bschultz Jun 19 '14 at 21:00
  • Really, the M$ docs are full of examples using LIMIT, they just aren't obvious about it not working with sqlclient. Thanks! Now I just have to figure out how to mark your answer as an answer... – user3758018 Jun 19 '14 at 21:10

0 Answers0