T-Sql – Keeping Top n rows in a table

The title sounds like related to a logging operation, isn’t it? Well yes, it is.In an existing logging operation, I needed to ensure that the number of log entries remained below a specified threshhold. And I came up with the following sql quickly: DECLARE...

Limiting rows in Sql Server

One problem I have always faced with Sql Server (more so, after I used MySql, and saw that MySql allows this) is to find a way to limit the number of rows being fetched in a SELECT query.Although Sql Server provides a ROWCOUNT statement & TOP clause for the SELECT...