Create trigger after insert

2019-08-26 05:26发布

问题:

In my table I have besides rest following fields

Email 
UpperEmail

I should create trigger which will populate UpperEmail field with Email value transformed to upper letters. How to do this?

回答1:

Instead of having a separate column for UpperEmail, I would suggest that you create a computed column that does this. With a computed column, you would not need to use a trigger.

Ex:

Alter Table YourTableName Add UpperEmail As Upper(Email)


回答2:

As an alternative solution, have you thought about storing your e-mail addresses in a column with a case-insensitive collation? I ask because when I see someone caring about UPPER(value) or LOWER(value), it's so they can compare in a case-insensitive manner.