Pergunta

I have an application where I create a big SQL query dynamically for SQL server 2008. This query is based on various search criteria which the user might give such as search by lastname, firstname, ssn etc.

The requirement is that if the user gives a condition due to which the formed query might return a lot of rows(configurable for max N rows), then the application must send back a message instead to the user saying that he needs to refine his search query as the existing query will return too many rows.

I would not want to bring back say, 5000 rows to the client and then discard that data just to show the user an error. What is an efficient way to tackle this issue?

Foi útil?

Solução

why not just show the first N rows, AND the message? limit the rows returned to N+1 and if the count of returned rows is > N then show the message :)

if you just want to check how many rows WOULD be returned by a query then select count(id) (or some column name) instead of select *

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top