In SqlServer 2005, LIMIT is invalid.
Instead, do something like:
SELECT TOP(5) * FROM Comment WHERE user_id = x ORDER BY comment_id ASC
Note that this assumes that comment_id is monotonically increasing, which may not always be a valid assumption for identity fields (if you need to renumber them, for example). You might want to consider an alternative field, but the basic structure will be the same.
Please note that if you ordered by date, you would like to sort in descending order, and not in ascending order, for example.
SELECT TOP(5) * FROM Comment WHERE user_id = x ORDER BY last_updated DESC
Nathan
source share