Report on data in SQL database that does not meet certain rules I need to generate reports in a web app for rows in my tables that do not meet specific rules. I want to allow the data to be inserted into the tables, but I want to be able to flag it so that a user can return later and correct it. An example of some of the rules I'm checking against are that strings are in certain formats and lengths (like a license plate) and I'm also checking for validity on dates. I expect to have more of these rules come up in the future, so I'm looking for a scalable solution. My application is in .NET, but I've been told it would be better to do this on the DB side rather than in code. Should I be looking into implementing some type of rules engine with stored procedures?
If you're going to maintain some sort of flag indicating which rows have problems (which makes sense if you have a lot of rows, 99.9%+ of which will be fine), then I'd use a trigger to check for the conditions. That way there's one check, only done when a row is actually added or changed.