It sounds to me like you are looking for an Instead Of INSERT Trigger. Basically what it does is it allows you, in SQL, to look at the data before it is inserted (or update or deleted if you want) and determine if you want to allow the insertion to happen. In this way, you could limit the data going into your database.
For example, you might have a table that contained people's votes on surveys. You could set up a rule that limited people to onl one vote per day per survey. Since the person would be allowed to vote once per day, you couldn't use a
UNIQUE
constraint unless the Date field was the new Date type that just stored the date and not the time. The Instead Of trigger could check to see if that person already had an entry for today. If so, the change could be rejected.
A word of caution: triggers take up time in your database. The more you write, the slower your database will run. Use them wisely and only when a more efficient method is not available. For instance, the
UNIQUE
constraint in the above example would work for a lot of circumstances and should be tried first.
To learn more about triggers, read this article:
http://www.google.com/url?sa=t&rct=j&q=&esrc=s&frm=1&source=web&cd=6&ved=0CG4QFjAF&url=http%3A%2F%2Fwww.codeproject.com%2FArticles%2F25600%2FTriggers-Sql-Server&ei=nHfbT72_Kqf96gGbgLW8Cw&usg=AFQjCNE2-wxIYQDD3xvXqkSGPlvJ-HSAhw[
^]
Just make sure you do an Instead Of trigger instead of an After trigger. After is too late.