PDA

View Full Version : Limiting the number of records to be displayed SQL Server



Jeniveve
Aug 7th, 2005, 03:53 AM
I am trying to write a SELECT statement that limits the number of records to be shown. I want to use the LIMIT command since it seems so simple to use however for some reason, I am getting a syntax error when I do...The SELECT statement is "SELECT title, eventDate, startTime, endTime, location, short FROM events LIMIT 3,2" and the error is Incorrect syntax near 3.

Does anyone know why this is creating an error?

Any information would be greatly appreciated.

Thank you!
Jen

Brandoe85
Aug 7th, 2005, 04:05 AM
SQL server does not have the 'limit' clause like mysql does, you'll have to use the TOP clause in sql server.
Select TOP 5 fldName from tblName

Good luck

Jeniveve
Aug 7th, 2005, 03:52 PM
Thanks a lot Brando, that worked great!!
Jen