I find that there are only after and instead of triggers in sql server. And it is illegal to modify the values in the inserted pesudo table. Then my problem occurs: If I want to check the data which is going to be inserted into my table, and when the data violates my constraints I should modify these values to default values, how to do it ? How about updateing the values after inserted ? However, if there’s no primary key or colum which is unique in my table, how can I locate the row just inserted and then update it ?
Share
Basically, with an
INSTEAD OF INSERTtrigger, you can achieve what you’re looking for – just read out the data from theINSERTEDpseudo table, modify it, and insert it into the tableSo your trigger would look something like this:
Of course, you could also add e.g. checks in the form of
WHEREclause to thatSELECT .... FROM INSERTEDstatement to e.g. ignore certain rows – the possibilities are endless!