I have an application that has some in line SQL that builds a query in a webpage that selects * from a view if a user does not enter in any search criteria on the page. This happens accidentally (no one clicks search wide open on purpose in this case) and the page takes a while to load and a lot of times throws out of memory errors depending on the machine hardware.
I was wondering if there was a way to limit the number of records returned from a view, but also allow the view to return the expected search criteria when the user actually enters something into the search boxes.
Without really thinking I added a TOP (250) to the view, and then realized that there are only 250 records to search through when using the field parameters so that won't work. I was trying to think of a quick way I could alter the view to only return 250 records if there was no WHERE clause in the selection, but also allow for the entire dataset to be searched and have the requested data returned.
As I'm tying this, I'm thinking that's not possible and I'll have to get the application folks to make the change on their side to prevent wide open searches, but they're a lot slower
Since I typed this out I figured I'd ask anyway just in case there's a slick dynamic way to handle this.